mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Started to document autocompltion users module
This commit is contained in:
parent
c89dff053d
commit
a138b8c02e
@ -1,5 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
# -*- coding: utf-8 -*-
|
||||
""" Autocompletion users feature for TWBlue. This package contains all needed code to support this feature, including automatic addition of users, management and code to show the autocompletion menu when an user is composing a tweet. """
|
||||
from . import completion, settings
|
||||
|
@ -1,15 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""" Module to display the user autocompletion menu in tweet or direct message dialogs. """
|
||||
import output
|
||||
from . import storage
|
||||
from . import wx_menu
|
||||
|
||||
class autocompletionUsers(object):
|
||||
def __init__(self, window, session_id):
|
||||
""" Class constructor. Displays a menu with users matching the specified pattern for autocompletion.
|
||||
|
||||
:param window: A wx control where the menu should be displayed.
|
||||
:type window: wx.Dialog
|
||||
:param session_id: Session ID which calls this class. We will load the users database from this session.
|
||||
:type session_id: str.
|
||||
"""
|
||||
super(autocompletionUsers, self).__init__()
|
||||
self.window = window
|
||||
self.db = storage.storage(session_id)
|
||||
|
||||
def show_menu(self, mode="tweet"):
|
||||
""" displays a menu with possible users matching the specified pattern.
|
||||
|
||||
this menu can be displayed in tweet dialogs or in any other dialog where an username is expected. For tweet dialogs, the string should start with an at symbol (@), otherwise it won't match the pattern.
|
||||
|
||||
Of course, users must be already loaded in database before attempting this.
|
||||
|
||||
If no users are found, an error message will be spoken.
|
||||
|
||||
:param mode: this controls how the dialog will behave. Possible values are 'tweet' and 'dm'. In tweet mode, the matching pattern will be @user (@ is required), while in 'dm' mode the matching pattern will be anything written in the text control.
|
||||
:type mode: str
|
||||
"""
|
||||
position = self.window.text.GetInsertionPoint()
|
||||
if mode == "tweet":
|
||||
text = self.window.text.GetValue()
|
||||
|
Loading…
Reference in New Issue
Block a user