예제 #1
0
    def __initCtrl(self):
        """
        Initialize the controls.
        """
        # IDs
        [self.__editorID] = PyutUtils.assignID(1)

        sizer = BoxSizer(VERTICAL)

        self.__lblEditor = StaticText(self, -1, _("Editor"))
        self.__txtEditor = TextCtrl(self, -1, size=(100, 20))
        sizer.Add(self.__lblEditor, 0, ALL, DlgFastEditOptions.GAP)
        sizer.Add(self.__txtEditor, 0, ALL, DlgFastEditOptions.GAP)

        hs = BoxSizer(HORIZONTAL)
        btnOk = Button(self, ID_OK, _("&OK"))
        hs.Add(btnOk, 0, ALL, DlgFastEditOptions.GAP)
        sizer.Add(hs, 0, CENTER)

        self.SetAutoLayout(True)
        self.SetSizer(sizer)
        sizer.Fit(self)
        sizer.SetSizeHints(self)

        btnOk.SetDefault()

        self.Bind(EVT_TEXT, self.__OnText, id=self.__editorID)

        self.__setValues()
        self.Center()

        self.__changed: bool = False
예제 #2
0
파일: log.py 프로젝트: Petrica-Taras/Tkad
    def __init__(self, master):
        TextCtrl.__init__(self, master, style = TE_MULTILINE)
        self.master = master
        self.SetBackgroundColour("Black")          # TODO: move into settings object
        self.SetDefaultStyle(TextAttr("GREEN"))    # TODO: move into settings object

        self.write("Tkad started!\n\n")
예제 #3
0
    def _createMethodInformation(self) -> FlexGridSizer:

        # Txt Ctrl Name
        lblName: StaticText = StaticText(self, ID_ANY, _("Name"))
        self._txtName: TextCtrl = TextCtrl(self,
                                           ID_TXT_METHOD_NAME,
                                           "",
                                           size=(125, -1))
        self.Bind(EVT_TEXT, self._evtMethodText, id=ID_TXT_METHOD_NAME)

        # Txt Ctrl Modifiers
        lblModifiers: StaticText = StaticText(self, ID_ANY, _("Modifiers"))
        self._txtModifiers: TextCtrl = TextCtrl(self,
                                                ID_ANY,
                                                "",
                                                size=(125, -1))

        # Txt Ctrl Return Type
        lblReturn: StaticText = StaticText(self, ID_ANY, _("Return type"))
        self._txtReturn: TextCtrl = TextCtrl(self, ID_ANY, "", size=(125, -1))

        methodInfoContainer: FlexGridSizer = FlexGridSizer(cols=3,
                                                           hgap=6,
                                                           vgap=6)

        methodInfoContainer.AddMany([
            lblName, lblModifiers, lblReturn, self._txtName,
            self._txtModifiers, self._txtReturn
        ])

        return methodInfoContainer
예제 #4
0
    def _SetBestInsertion(cls, ctrl: wx.TextCtrl, orig_text: str,
                          orig_insertion: int):
        """Set the most natural insertion point for a paired-number text control.

        The format of the text control must be "X,Y" where X, Y are numbers, allowing whitespace.
        This should be called after the text control is manually changed by View during user's
        editing. Normally if the text changes the caret will be reset to the 0th position, but this
        calculates a smarter position to place the caret to produce a more natural behavior.

        Args:
            ctrl: The text control, whose value is already programmatically changed.
            orig_text: The value of the text control before it was changed.
            orig_insertion: The original caret position from GetInsertionPoint().
        """
        new_text = ctrl.GetValue()
        mid = orig_text.index(',')

        if orig_insertion > mid:
            ctrl.SetInsertionPoint(len(new_text))
        else:
            tokens = new_text.split(',')
            assert len(tokens) == 2

            left = tokens[0].strip()
            lstart = new_text.index(left)
            lend = lstart + len(left)
            ctrl.SetInsertionPoint(lend)
예제 #5
0
    def CreateCenterSection(self):
        sizer = wx.BoxSizer(orient=wx.VERTICAL)
        top = wx.BoxSizer(orient=wx.HORIZONTAL)

        submit_button = wx.Button(self, label="Search", size=wx.Size(10, 30))
        submit_button.Bind(wx.EVT_BUTTON, self.SearchFieldInput)

        searchField = TextCtrl(self, size=wx.Size(250, 30))
        #searchField.Bind(wx.EVT_KEY_UP, self.SearchFieldInput)
        searchField.SetFont(self.APPFONT)
        searchField.SetHint("Search for a card name here")
        searchField.SetFocus()

        cardInfo = StaticText(
            self, label="No card selected", size=wx.Size(250, 500))

        cardInfo.SetFont(self.APPFONT)
        cardInfo.SetBackgroundColour("white")

        self.cardInfo = cardInfo
        self.searchField = searchField

        top.Add(searchField, 2, wx.EXPAND, 1)
        top.Add(submit_button, 1, wx.EXPAND, 5)

        sizer.Add(top, 0, wx.EXPAND, 1)
        sizer.Add(cardInfo, 0, wx.EXPAND, 10)
        sizer.SetSizeHints(self)
        self.centerSizer = sizer

        return sizer
예제 #6
0
    def __init__(self, parent, label, initial=""):
        super().__init__(parent)

        sizer = BoxSizer(HORIZONTAL)
        self._text_input = TextCtrl(self)
        self._text_input.SetValue(initial)
        sizer.Add(self._text_input)
        sizer.Add(StaticText(self, label=label))
        self.SetSizer(sizer)
예제 #7
0
 def __init__(self, *args, **kargs):
     set_default_font()
     TextCtrl.__init__(self, *args, **kargs)
     self.SetFont(font)
     self.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
     self.Bind(wx.EVT_KILL_FOCUS, self.onKillFocus)
     self.Bind(wx.EVT_SIZE, self.onSize)
     self._data = ''
     self._mode = 'trunc'
예제 #8
0
 def SetValue(self, value):
     self._data = value
     if self._mode != 'trunc':
         return TextCtrl.SetValue(self, value)
     w, h = self.GetClientSize()
     if self.HasFocus():
         return TextCtrl.SetValue(self, value)
     else:
         value = truncate_str(value, w / font_w)
         TextCtrl.SetValue(self, value)
예제 #9
0
    def __init__(self, parent, ID, pyutUseCase):
        """
        Constructor.

        @since 1.0
        @author Philippe Waelti <*****@*****.**>
        """
        super().__init__(parent,
                         ID,
                         _("Use Case Edit"),
                         style=RESIZE_BORDER | CAPTION)

        # Associated PyutUseCase
        self._pyutUseCase = pyutUseCase

        self.SetAutoLayout(True)

        self._text = self._pyutUseCase.getName()
        self._returnAction = -1  # describe how the user exited the dialog box

        label = StaticText(self, -1, _("Use case text"))

        self._txtCtrl = TextCtrl(self,
                                 TXT_USECASE,
                                 self._text,
                                 size=(400, 180),
                                 style=TE_MULTILINE)
        self._txtCtrl.SetFocus()

        # text events
        self.Bind(EVT_TEXT, self._onTxtChange, id=TXT_USECASE)

        btnOk = Button(self, OK, _("&Ok"))
        btnOk.SetDefault()
        btnCancel = Button(self, CANCEL, _("&Cancel"))

        self.Bind(EVT_BUTTON, self._onCmdOk, id=OK)
        self.Bind(EVT_BUTTON, self._onCmdCancel, id=CANCEL)

        szrButtons = BoxSizer(HORIZONTAL)
        szrButtons.Add(btnOk, 0, RIGHT, 10)
        szrButtons.Add(btnCancel, 0, ALL)

        szrMain = BoxSizer(VERTICAL)
        szrMain.Add(label, 0, BOTTOM, 5)
        szrMain.Add(self._txtCtrl, 1, EXPAND | BOTTOM, 10)
        szrMain.Add(szrButtons, 0, ALIGN_CENTER_HORIZONTAL)
        # Border
        szrBorder = BoxSizer(VERTICAL)
        szrBorder.Add(szrMain, 1, EXPAND | ALL, 10)
        self.SetSizer(szrBorder)
        szrBorder.Fit(self)

        self.Centre()
        self.ShowModal()
예제 #10
0
    def __create_widgets(self):
        sizer = GridBagSizer(5, 5)

        row = 0
        col = 0

        # first row
        label = StaticText(self, label=u'Selected area:')
        sizer.Add(label, pos=(row, col))

        col += 1
        self.txt_selected_area = TextCtrl(self, value=u'(0, 0, 0, 0)')
        sizer.Add(self.txt_selected_area,
                  pos=(row, col),
                  flag=FLAG_ALL_AND_EXPAND)

        col += 1
        label = StaticText(self, label=u'Class name:')
        sizer.Add(label, pos=(row, col))

        col += 1
        self.txt_class_name = TextCtrl(self)
        sizer.Add(self.txt_class_name,
                  pos=(row, col),
                  flag=FLAG_ALL_AND_EXPAND)

        col += 1
        self.bth_reload_img = Button(self, label=u'Reload image')
        self.bth_reload_img.Bind(EVT_BUTTON, self.__load_img)
        sizer.Add(self.bth_reload_img,
                  pos=(row, col),
                  flag=FLAG_ALL_AND_EXPAND)

        col += 1
        self.btn_generate = Button(self, label=u'Generate')
        self.btn_generate.Bind(EVT_BUTTON, self.generate)
        sizer.Add(self.btn_generate, pos=(row, col), flag=FLAG_ALL_AND_EXPAND)

        # second row
        row += 1
        col = 0
        self.select_image_panel = SelectableImagePanel(self)
        self.select_image_panel.static_bitmap.Bind(EVT_MOTION,
                                                   self._on_mouse_move)
        sizer.Add(self.select_image_panel,
                  pos=(row, col),
                  span=(1, 6),
                  flag=FLAG_ALL_AND_EXPAND)

        sizer.AddGrowableCol(1, 1)
        sizer.AddGrowableRow(row, 1)

        self.SetSizer(sizer)
예제 #11
0
    def __init__(self):
        TaskBarIcon.__init__(self)
        self.SetIcon(Icon(self.ICON), self.TITLE)  # 设置图标和标题
        self.Bind(EVT_MENU, self.onAbout, id=self.ID_ABOUT)  # 绑定“关于”选项的点击事件
        self.Bind(EVT_MENU, self.onExit, id=self.ID_EXIT)  # 绑定“退出”选项的点击事件
        self.Bind(EVT_MENU, self.onUpload, id=self.ID_UPLOAD)
        self.Bind(EVT_MENU, self.OnLogin, id=self.ID_LOGIN)

        self.frame = Frame(parent=None, title='登录', size=(285, 160))
        self.frame.Bind(EVT_CLOSE, lambda event: self.frame.Show(False))

        panel = Panel(self.frame, -1)
        label_user = StaticText(panel, -1, "账号:", pos=(10, 10))
        label_pass = StaticText(panel, -1, "密码:", pos=(10, 50))

        self.entry_user = TextCtrl(panel, -1, size=(210, 20), pos=(50, 10))
        self.entry_pass = TextCtrl(panel, -1, size=(210, 20), pos=(50, 50), style=TE_PASSWORD)

        self.but_login = Button(panel, -1, "登陆", size=(50, 30), pos=(10, 80))
        self.but_register = Button(panel, -1, "注册SM.MS账号", size=(110, 30), pos=(150, 80))
        self.but_not_login = Button(panel, -1, "免登陆使用", size=(80, 30), pos=(65, 80))

        self.but_login.Bind(EVT_BUTTON, self.on_but_login)
        self.but_register.Bind(EVT_BUTTON, self.on_but_register)
        self.but_not_login.Bind(EVT_BUTTON, self.on_but_not_login)

        self.frame.Center()
        token = init_config()
        if token == '0':
            self.frame.Show(True)
        else:
            self.frame.Show(False)

        self.frame.SetMaxSize((285, 160))
        self.frame.SetMinSize((285, 160))
        ThreadKey(self)

        self.frame2 = Trans(parent=None, title='上传中', size=(50, 20))
        self.frame2.Center()
        self.frame2.Show(False)

        self.frame3 = Trans(parent=None, title='上传成功', size=(50, 20))
        self.frame3.Center()
        self.frame3.Show(False)

        self.frame4 = Trans(parent=None, title='上传失败', size=(50, 20))
        self.frame4.Center()
        self.frame4.Show(False)

        self.frame5 = Trans(parent=None, title='每分钟限制上传20张,请等待冷却', size=(200, 20))
        self.frame5.Center()
        self.frame5.Show(False)
예제 #12
0
class SimpleInput(Panel):
    def __init__(self, parent, label, initial=""):
        super().__init__(parent)

        sizer = BoxSizer(HORIZONTAL)
        self._text_input = TextCtrl(self)
        self._text_input.SetValue(initial)
        sizer.Add(self._text_input)
        sizer.Add(StaticText(self, label=label))
        self.SetSizer(sizer)

    def get_value(self):
        return self._text_input.GetValue()
예제 #13
0
 def set_field_background(field: wx.TextCtrl, color: wx.Colour) -> None:
     """
     Set background color for a field.
     :param field: wx.TextCtrl.
     :param color: The wx.Color to set.
     :return: None
     """
     field.SetBackgroundColour(color)
     style_carrier = wx.TextAttr()
     # Set color for the current text separately, it does not work with just background color
     field.GetStyle(0, style_carrier)
     style_carrier.SetBackgroundColour(color)
     field.SetStyle(0, len(field.GetValue()), style_carrier)
예제 #14
0
def _getCharIndexUnderMouse(ctrl: wx.TextCtrl) -> Optional[int]:
    """ Get the index of the character under the mouse.
	@note: Assumes all characters are on one line
	"""
    mousePos = wx.GetMousePosition()
    toClient = ctrl.ScreenToClient(mousePos)
    # This hit test is inaccurate, there seems to be a bug in wx.
    # When the mouse is above or before the window it is counted as a hit.
    # Above: mouseY is less than windowY I.E. when 'toClient.y' < 0
    # Before: mouseX is less than windowX I.E. when 'toClient.x' < 0
    result, index = ctrl.HitTestPos(toClient)
    if result == wx.TE_HT_ON_TEXT and toClient.y > 0 and toClient.x > 0:
        return index
    return None
예제 #15
0
    def __init__(self, app: App):
        super(Frame, self).__init__(None)
        self.editor = TextCtrl(self, 101, style=TE_MULTILINE)
        self.stat: StatusBar = self.CreateStatusBar()
        self.stat.SetFieldsCount(2)
        self.stat.SetStatusWidths([-1, -5])
        self.SetTitle(f"{BASETITLE} - *Untitled*")
        self.SetSize(720, 540)
        self.File: str = None
        self.changed = False

        menubar: MenuBar = MenuBar()
        edit_menu: Menu = Menu()
        file_menu: Menu = Menu()

        edit_menu.Append(1, "&Preview\tCtrl+P")
        edit_menu.Append(2, "Post")
        edit_menu.AppendSeparator()
        edit_menu.Append(7, "&Ruby\tCtrl+R")
        edit_menu.Append(9, "&Dotmarks\tCtrl+Shift+D")
        edit_menu.Append(8, "&Paragraph\tCtrl+Space")

        file_menu.Append(3, "&New\tCtrl+N")
        file_menu.Append(4, "&Open\tCtrl+Shift+O")
        file_menu.AppendSeparator()
        file_menu.Append(5, "&Save as\tCtrl+Shift+S")
        file_menu.Append(6, "&Save\tCtrl+S")

        menubar.Append(file_menu, "&File")
        menubar.Append(edit_menu, "&Edit")

        self.SetMenuBar(menubar)
        self.Bind(EVT_MENU, self.Preview, id=1)
        self.Bind(EVT_MENU, self.Post, id=2)
        self.Bind(EVT_MENU, self.New, id=3)
        self.Bind(EVT_MENU, self.Open, id=4)
        self.Bind(EVT_MENU, self.SaveAs, id=5)
        self.Bind(EVT_MENU, self.Save, id=6)
        self.Bind(EVT_MENU, self.SetRuby, id=7)
        self.Bind(EVT_MENU, self.SetParagraphSpaces, id=8)
        self.Bind(EVT_MENU, self.Dotmarks, id=9)

        self.pvframe = HideFrame(None, -1, "プレビュー")
        self.pvctrl: WebView = WebView.New(self.pvframe)
        self.pvctrl.SetCanFocus(False)
        self.pvframe.SetCanFocus(False)
        self.Bind(EVT_TEXT, self.Reload, id=101)
        app.SetTopWindow(self)
        self.application = app
        self.Show()
예제 #16
0
class MainFrame(Frame):
    """A webbrowser frame."""

    def __init__(self):
        self.loaded = False
        super().__init__(None)
        p = Panel(self)
        s = BoxSizer(VERTICAL)
        ts = BoxSizer(HORIZONTAL)
        ts.Add(StaticText(p, label='A&ddress'), 0, GROW)
        self.address = TextCtrl(p, style=TE_PROCESS_ENTER)
        self.address.Bind(EVT_TEXT_ENTER, self.on_enter)
        ts.Add(self.address, 1, GROW)
        s.Add(ts, 0, GROW)
        self.html = WebView.New(p)
        self.html.Bind(EVT_WEBVIEW_LOADED, self.on_load)
        self.html.Bind(EVT_WEBVIEW_ERROR, self.on_error)
        self.html.Bind(EVT_WEBVIEW_TITLE_CHANGED, self.on_title)
        s.Add(self.html, 1, GROW)
        p.SetSizerAndFit(s)

    def SetTitle(self, title):
        """Set the title with the app name."""
        if not title:
            title = 'Blank'
        return super().SetTitle('%s - PyBrowse' % title)

    def on_enter(self, event):
        """Load this address."""
        self.html.LoadURL(self.address.GetValue())

    def on_load(self, event):
        """Set the window title."""
        self.address.SetValue(self.html.GetCurrentURL())
        self.address.SelectAll()
        if self.loaded:
            Bell()
            self.html.SetFocus()
        else:
            self.loaded = True

    def on_title(self, event):
        """Change the window title."""
        self.SetTitle(event.GetString())

    def on_error(self, event):
        """Show an error."""
        MessageBox(event.GetString(), caption='Error', style=ICON_EXCLAMATION)
예제 #17
0
    def __init__(self, parent, title, values):
        Dialog.__init__(self,
                        parent,
                        title=title,
                        style=DEFAULT_DIALOG_STYLE | RESIZE_BORDER)
        self.values = None

        sizer = GridBagSizer(5, 5)
        row = 0
        self.labels = []
        self.txt_ctrls = []
        for value in values:
            label = StaticText(self, label=value)
            self.labels.append(label)
            sizer.Add(label, pos=(row, 0), flag=ALIGN_RIGHT)

            txtctrl = TextCtrl(self)
            self.txt_ctrls.append(txtctrl)
            sizer.Add(txtctrl, pos=(row, 1), flag=FLAG_ALL_AND_EXPAND)
            row += 1

        self.btn_cancel = Button(self, label=u'Cancel')
        self.btn_cancel.Bind(EVT_BUTTON, self.__on_btn)
        sizer.Add(self.btn_cancel, pos=(row, 0), flag=FLAG_ALL_AND_EXPAND)

        self.btn_ok = Button(self, label=u'OK')
        self.btn_ok.Bind(EVT_BUTTON, self.__on_btn)
        sizer.Add(self.btn_ok, pos=(row, 1), flag=FLAG_ALL_AND_EXPAND)

        sizer.AddGrowableCol(1)
        self.SetSizerAndFit(sizer)
        self.SetSize(400, self.GetSizeTuple()[1])
예제 #18
0
파일: widgets.py 프로젝트: 4thel00z/re-wx
def textctrl(element, instance: wx.TextCtrl):
    props = {**element['props']}
    value = props.get('value')
    try:
        del props['value']
    except KeyError:
        pass
    set_basic_props(instance, props)
    if 'editable' in props:
        instance.SetEditable(props['editable'])
    if value is not None:
        instance.ChangeValue(value)
    instance.Unbind(wx.EVT_TEXT)
    if 'on_change' in props:
        instance.Bind(wx.EVT_TEXT, props['on_change'])
    return instance
예제 #19
0
    def __init__(self, parent: Window, dialogIdentifier, pyutNote: PyutNote):
        """

        Args:
            parent:             parent window to center on
            dialogIdentifier:   An identifier for the dialog
            pyutNote:           Model object we are editing
        """
        super().__init__(parent, dialogIdentifier, _("Note Edit"))

        self._pyutNote: PyutNote = pyutNote

        label: StaticText = StaticText(self, ID_ANY, _("Note text"))
        self._txtCtrl: TextCtrl = TextCtrl(self,
                                           TXT_NOTE,
                                           self._pyutNote.content,
                                           size=(400, 180),
                                           style=TE_MULTILINE)
        self._txtCtrl.SetFocus()

        self._setupMainDialogLayout(self._txtCtrl, label)

        self.Bind(EVT_TEXT, self._onTxtNoteChange, id=TXT_NOTE)

        self.Centre()
예제 #20
0
class DialogWithText(Dialog):
    def __init__(self, parent, title, text=None):
        Dialog.__init__(self,
                        parent,
                        title=title,
                        style=DEFAULT_DIALOG_STYLE | RESIZE_BORDER)
        self.SetTitle(title)
        self.SetSize(600, 400)

        sizer = BoxSizer(VERTICAL)

        self.txt_ctrl = TextCtrl(self,
                                 style=TE_MULTILINE | TE_READONLY | HSCROLL)
        if text:
            self.txt_ctrl.SetValue(text)
        sizer.Add(self.txt_ctrl, 1, flag=FLAG_ALL_AND_EXPAND)

        self.btn_ok = Button(self, label=u'OK')
        self.btn_ok.Bind(EVT_BUTTON, self.__close)
        sizer.Add(self.btn_ok, flag=CENTER)

        self.SetSizer(sizer)

    def __close(self, evt):
        self.EndModal(ID_OK)
        self.Hide()
예제 #21
0
    def __init__(self, parent: Window, labelText: str,
                 valueChangedCallback: Callable):
        """

        Args:
            parent:     The parent window
            labelText:  How to label the text input
            valueChangedCallback:  The method to call when the value changes;  The method should expect the
            first parameter to be a string argument that is the new value
        """

        super().__init__(HORIZONTAL)

        self._textId: int = wxNewIdRef()

        self._callback: Callable = valueChangedCallback

        textLabel: StaticText = StaticText(parent, ID_ANY, labelText)
        textControl: TextCtrl = TextCtrl(parent, self._textId)

        self.Add(textLabel, WX_SIZER_CHANGEABLE, ALL | ALIGN_CENTER_VERTICAL,
                 TextContainer.HORIZONTAL_GAP)
        self.Add(textControl, WX_SIZER_CHANGEABLE, ALL,
                 TextContainer.HORIZONTAL_GAP)

        self._textControl: TextCtrl = textControl
        self._textValue: str = ''

        parent.Bind(EVT_TEXT, self._onTextValueChanged, id=self._textId)
예제 #22
0
    def __init__(self, parent, labelText: str, valueChangedCallback: Callable, textControlSize: Tuple = (315, -1)):
        """

        Args:
            parent:     The parent window

            labelText:  How to label the text input

            valueChangedCallback:  The method to call when the value changes;  The method should expect the
            first parameter to be a string argument that is the new value

            textControlSize:  A tuple of (width, height) for the text input
        """

        super().__init__(parent)

        self._textControlSize: Tuple = textControlSize
        self.SetSizerType('form')
        self._textId:  int = wxNewIdRef()

        self._callback: Callable = valueChangedCallback

        # noinspection PyUnusedLocal
        textLabel:   StaticText = StaticText(self, ID_ANY, labelText)
        textControl: TextCtrl   = TextCtrl(self, self._textId, "", size=self._textControlSize)
        # noinspection PyUnresolvedReferences
        textControl.SetSizerProps(expand=True, halign='right')

        self._textControl:  TextCtrl = textControl
        self._textValue:    str      = ''

        # noinspection PyUnresolvedReferences
        self.SetSizerProps(expand=True)
        parent.Bind(EVT_TEXT, self._onTextValueChanged, id=self._textId)
예제 #23
0
    def __init__(
        self,
        textCtrl: wx.TextCtrl,
        textCellIndex: int,
        startValue: float,
        originColor: wx.Colour,
        destColor: wx.Colour,
        durationSeconds: float,
    ):
        """
		:param textCtrl: the TextCtrl to perform the background colour animation on.
		:param textCellIndex: the character cell index that should be highlighted with the animation
		:param startValue: a percentage (0->1). At elapsed == 0 the colour transition will already be
			this far through. Allows for a beginning bump in the colour transition.
		:param originColor: The origin colour.
		:param destColor: The destination colour. Reached at elapsed == totalTime.
		:param durationSeconds: total time that the transition should take in seconds
		"""
        self._textCtrl = textCtrl
        self._textCellIndex = textCellIndex
        self._originColor = originColor
        self._destColor = destColor
        self._startValue = startValue
        self._durationSeconds = durationSeconds
        self._startTime = time.time()
        normalBGColor = textCtrl.GetBackgroundColour()
        self._currentAttr = self._normalBGStyle = createBackgroundColorTextAttr(
            normalBGColor)
예제 #24
0
    def __init__(self, parent, wxID, sourceCode: SourceCode):
        """
        We'll modify pyutMethod on OK
        Args:
            parent:
            wxID:
            sourceCode:
        """
        self._sourceCode:            SourceCode = sourceCode
        self._displayableSourceCode: str        = f'{osLineSep}'.join(sourceCode)

        super().__init__(parent, wxID, _('Method Code'), style=CAPTION | CLOSE_BOX | DIALOG_EX_METAL)

        self.Center(BOTH)
        panel: SizedPanel = self.GetContentsPane()

        panel.SetSizerType('vertical')

        self._txtCtrl: TextCtrl = TextCtrl(panel, TXT_CODE, self._displayableSourceCode, style=TE_MULTILINE)
        # This method is there but PyCharm cannot find it
        # noinspection PyUnresolvedReferences
        self._txtCtrl.SetSizerProps(expand=True)

        self.SetButtonSizer(self.CreateStdDialogButtonSizer(OK | CANCEL))

        self.Fit()
        self.SetMinSize(self.GetSize())

        self.Bind(EVT_TEXT,   self.__onSourceCodeChange, id=TXT_CODE)
        self.Bind(EVT_BUTTON, self.__onCmdOk, id=ID_OK)
        self.Bind(EVT_BUTTON, self.__onClose, id=ID_CANCEL)
        self.Bind(EVT_CLOSE,  self.__onClose)
예제 #25
0
    def __init__(self, parent: Window, dialogIdentifier,
                 document: PyutDocument):
        """

        Args:
            parent:             The parent window
            dialogIdentifier    An identifier for the dialog
            document:           The UML document we want to edit
        """
        super().__init__(parent, dialogIdentifier, _("Document Edit"))

        self.logger: Logger = getLogger(__name__)
        self._document: PyutDocument = document

        label: StaticText = StaticText(self, ID_ANY, _("Document Name"))
        self._nameEntry: TextCtrl = TextCtrl(parent=self,
                                             id=TXT_DOCUMENT_NAME,
                                             value=document.title)
        self._nameEntry.SetFocus()

        self._setupMainDialogLayout(self._nameEntry, label)

        self.Bind(EVT_TEXT, self._onDocumentNameChange, id=TXT_DOCUMENT_NAME)

        self.Centre()
        self.ShowModal()
예제 #26
0
 def __init__(self):
     self.loaded = False
     super().__init__(None)
     p = Panel(self)
     s = BoxSizer(VERTICAL)
     ts = BoxSizer(HORIZONTAL)
     ts.Add(StaticText(p, label='A&ddress'), 0, GROW)
     self.address = TextCtrl(p, style=TE_PROCESS_ENTER)
     self.address.Bind(EVT_TEXT_ENTER, self.on_enter)
     ts.Add(self.address, 1, GROW)
     s.Add(ts, 0, GROW)
     self.html = WebView.New(p)
     self.html.Bind(EVT_WEBVIEW_LOADED, self.on_load)
     self.html.Bind(EVT_WEBVIEW_ERROR, self.on_error)
     self.html.Bind(EVT_WEBVIEW_TITLE_CHANGED, self.on_title)
     s.Add(self.html, 1, GROW)
     p.SetSizerAndFit(s)
예제 #27
0
	def __init__(self, textCtrl: wx.TextCtrl):
		self._secondsOfHoverToActivate = config.conf["brailleViewer"]["secondsOfHoverToActivate"]
		self._secondsOfPostActivate = 0.4
		self._textCtrl = textCtrl
		self._normalBGColor = textCtrl.GetBackgroundColour()
		self._charIndex = None
		self._doneRouteCall = False
		self._cellAnimation: Optional[CharCellBackgroundColorAnimation] = None
		self._setStage(self.Stage.NOT_STARTED)
예제 #28
0
    def construct_common(self, is_new):
        self.label_warnings = StaticText(self, -1, '', style = wx.ALIGN_CENTER)
        self.label_warnings.SetForegroundColour(wx.Colour(224, 0, 0))
        self.clear_warning()

        needs_password =  self.protocolinfo.get('needs_password', True)
        self.label_screenname = StaticText(self, -1, self.screenname_name + ':', style = ALIGN_RIGHT)

        if needs_password:
            self.label_password = StaticText(self, -1, 'Password:'******'' and hasattr(self.protocolinfo, 'newuser_url'):
            sn = self.url_screenname   = wx.HyperlinkCtrl(self, -1, 'New User?',
                                                     getattr(self.protocolinfo, 'newuser_url'))
            sn.HoverColour = sn.VisitedColour = sn.NormalColour

        if needs_password and hasattr(self.protocolinfo, 'password_url'):
            password = self.url_password     = wx.HyperlinkCtrl(self, -1, 'Forgot Password?',
                                                     getattr(self.protocolinfo, 'password_url'))

            password.HoverColour = password.VisitedColour = password.NormalColour

        if self.protocolinfo.get('needs_smtp', False):
            self.email_address = TextCtrl(self, -1, value = getattr(self.account, 'email_address', ''), size = txtSize, validator=LengthLimit(1024))

        self.name = TextCtrl(self, -1, value=self.account.name, size=txtSize, validator=LengthLimit(1024))

        # disable editing of username if this account is not new
        if not self.new:
            self.name.SetEditable(False)
            self.name.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_SCROLLBAR))
        # self.name.Enable(self.new)

        if needs_password:
            password = self.account._decryptedpw()

            f = lambda p: TextCtrl(self, -1, value = p,
                                          size = txtSize, style = wx.TE_PASSWORD,
                                          validator = LengthLimit(128))
            try:
                self.password = f(password)
            except UnicodeDecodeError:
                self.password = f('')
예제 #29
0
 def field_from_value(self, window, value, field):
     item = None
     if isinstance(value, six.string_types):
         item = TextCtrl(window, value=value)
         field.text_type = STRING_SETTING
     elif isinstance(value, list):
         if isinstance(value[0], six.string_types):
             item = TextCtrl(window, value=", ".join(value))
             field.text_type = STRING_LIST_SETTING
         elif isinstance(value[0], numbers.Real):
             item = TextCtrl(window,
                             value=", ".join((str(x) for x in value)))
             field.text_type = NUMBER_LIST_SETTING
     elif isinstance(value, bool):
         item = CheckBox(window, -1, '', (120, 75))
         item.SetValue(value)
     elif isinstance(value, numbers.Real):
         item = TextCtrl(window, value=str(value))
         field.text_type = NUMBER_SETTING
     elif isinstance(value, dict):
         subpage = Panel(window)
         vbox = BoxSizer(VERTICAL)
         for lbl in sorted(value.keys()):
             hbox = BoxSizer(HORIZONTAL)
             value2 = value[lbl]
             label = StaticText(subpage, label=lbl)
             hbox.Add(label, flag=RIGHT, border=8)
             subfield = Field(None, lbl)
             item = self.field_from_value(subpage, value2, subfield)
             field.add_child(subfield)
             if item is not None:
                 hbox.Add(item, proportion=1)
             vbox.Add(hbox, flag=EXPAND | LEFT | RIGHT | TOP, border=5)
             vbox.Add((-1, 5))
         subpage.SetSizer(vbox)
         subpage.Show()
         item = subpage
     else:
         # This is left for bug reporting purposes.
         printer.out(("{} from the field {} was not assigned to " +
                      "{} because type {} wasn't properly handled.").format(
                          value, field, window, type(value)))
     field.widget = item
     return item
예제 #30
0
    def construct(self, inbox_url = None, compose_url = None):
        # construct GUI
        self.inbox_label = StaticText(self, -1, _('Enter a URL for the Inbox'))
        self.inbox_text = TextCtrl(self, -1, inbox_url or '')

        self.compose_label = StaticText(self, -1, _('Enter a URL for the Compose window'))
        self.compose_text = TextCtrl(self, -1, compose_url or '')

        # add tooltips
        self.inbox_label.SetToolTipString(self.inbox_tooltip)
        self.inbox_text.SetToolTipString(self.inbox_tooltip)
        self.compose_label.SetToolTipString(self.compose_tooltip)
        self.compose_text.SetToolTipString(self.compose_tooltip)

        # connect event handlers for disabling OK when there is missing
        # content.
        self.inbox_text.Bind(wx.EVT_TEXT, self.on_text)
        self.compose_text.Bind(wx.EVT_TEXT, self.on_text)
        self.on_text()
예제 #31
0
class InputWidget(Panel):
    """
    Widget for text input
    """
    _text_input = None
    _callback = None
    _reset = False

    def __init__(self,
                 parent,
                 callback,
                 text_button: str,
                 initial: str = "",
                 reset: bool = False) -> None:
        super().__init__(parent)
        self._reset = reset
        self._callback = callback

        with SimpleSizer(self, HORIZONTAL) as sizer:
            self._text_input = TextCtrl(self,
                                        size=(400, 20),
                                        style=TE_PROCESS_ENTER)
            self._text_input.SetValue(initial)
            self._text_input.Bind(EVT_TEXT_ENTER, self.button_callback)
            sizer.Add(self._text_input, 1, flag=TOP, border=1)

            button = SimpleButton(parent=self,
                                  callback=self.button_callback,
                                  text_button=text_button,
                                  size=(200, 22))

            sizer.Add(button)

    def button_callback(self, event):
        """
        Receive event after text input, and pass text to callback function
        :param event: Event
        :return: None
        """
        self._callback(self._text_input.GetValue())
        if self._reset:
            self._text_input.SetValue("")
예제 #32
0
 def __init__(self, master, resources): # resources - XML file
     TextCtrl.__init__(self, master, style = TE_MULTILINE)
     self.master = master
     
     self.__XMLfile = resources