Ejemplo n.º 1
0
    def __createSimpleGridOptions(self) -> BoxSizer:

        szrSimple: BoxSizer = BoxSizer(VERTICAL)

        cbEnableBackgroundGrid: CheckBox = CheckBox(
            self, self.enableBackgroundGridID, _('Enable Background Grid'))
        cbSnapToGrid: CheckBox = CheckBox(self, self.snapToGridID,
                                          _('Snap to Grid'))

        box: StaticBox = StaticBox(self, ID_ANY, _("Grid Interval"))
        szrGridInterval: StaticBoxSizer = StaticBoxSizer(
            box, HORIZONTAL | ALIGN_LEFT)

        scGridInterval: SpinCtrl = SpinCtrl(self, self.scGridIntervalID, "")

        szrGridInterval.Add(scGridInterval, 0, LEFT | RIGHT,
                            BackgroundPreferences.HORIZONTAL_GAP)

        szrSimple.Add(cbEnableBackgroundGrid, 0, LEFT | RIGHT,
                      BackgroundPreferences.VERTICAL_GAP)
        szrSimple.Add(cbSnapToGrid, 0, LEFT | BOTTOM,
                      BackgroundPreferences.VERTICAL_GAP)

        szrSimple.AddSpacer(BackgroundPreferences.VERTICAL_GAP)
        szrSimple.Add(szrGridInterval, 0, LEFT | RIGHT | TOP,
                      BackgroundPreferences.VERTICAL_GAP)

        self._cbEnableBackgroundGrid: CheckBox = cbEnableBackgroundGrid
        self._cbSnapToGrid: CheckBox = cbSnapToGrid
        self._scGridInterval: SpinCtrl = scGridInterval

        return szrSimple
Ejemplo n.º 2
0
    def _createControls(self):
        """
        Creates the panel's controls and stashes them as private instance variables
        """
        self._textId = wxNewIdRef()

        self._cacheOptionControl         = CheckBox(parent=self, label="Allow Todoist Cache Cleanup", id=ID_ANY)
        self._tasksInParentOption        = CheckBox(parent=self, label="Single Todoist Project",     id=ID_ANY)
        self._parentProjectNameContainer = TextContainer(parent=self, labelText='Todoist Project Name:',
                                                         valueChangedCallback=self.__onParentProjectNameChange)
Ejemplo n.º 3
0
    def construct(self):
        'Construct GUI components.'

        self.header = StaticText(self, -1, _('Update Frequency:'))
        self.header.SetBold()

        self.desc = AutoHeightStaticText(self, -1, UPDATE_DESC_TEXT)
        self.desc.MinSize = wx.Size(40, -1)

        self.update_texts = {}  # "Tweets every"
        self.choices = {}  # "0 - 10 minutes"

        # Build StaticText, Choice for each update option.
        for i, (name, guistring) in enumerate(UPDATE_TYPES):
            self.update_texts[name] = StaticText(self, -1, guistring)
            self.choices[name] = Choice(self, choices=UPDATE_GUI_STRINGS)

        self.total = StaticText(self, style=ALIGN_CENTER)
        self.total.SetBold()

        self.auto_throttle = CheckBox(
            self,
            label=_('Auto-throttle when Twitter lowers the rate limit.'),
            name='auto_throttle')

        if self.show_server_options:
            self.server_text = StaticText(self, -1, _('Server'))
            self.server = wx.TextCtrl(self, -1)
Ejemplo n.º 4
0
    def _createControls(self):
        """
        Creates the main control and stashes them as private instance variables
        """

        self.__cbCenterAppOnStartup: CheckBox = CheckBox(
            self, self.__centerAppOnStartupId, _('Center Pyut on Startup'))

        mainSizer: BoxSizer = BoxSizer(VERTICAL)

        mainSizer.Add(self.__cbCenterAppOnStartup, 0, ALL,
                      PositioningPreferences.VERTICAL_GAP)
        mainSizer.Add(self.__createAppPositionControls(), 0, ALL,
                      PositioningPreferences.VERTICAL_GAP)
        mainSizer.Add(self.__createAppSizeControls(), 0, ALL,
                      PositioningPreferences.VERTICAL_GAP)

        self._setControlValues()

        self.Bind(EVT_CHECKBOX,
                  self.__onCenterOnStartupChanged,
                  id=self.__centerAppOnStartupId)

        self.SetAutoLayout(True)
        self.SetSizer(mainSizer)
Ejemplo n.º 5
0
    def __createTextStyleContainer(self, parent: Window) -> BoxSizer:

        styleContainer: BoxSizer = BoxSizer(HORIZONTAL)

        self._cbBoldText = CheckBox(parent=parent,
                                    id=self._cbBoldTextId,
                                    label=_('Bold Text'))
        self._cbItalicizeText = CheckBox(parent=parent,
                                         id=self._cbItalicizeTextId,
                                         label=_('Italicize Text'))

        styleContainer.Add(self._cbBoldText, 0, ALL,
                           TextAttributesContainer.HORIZONTAL_GAP)
        styleContainer.Add(self._cbItalicizeText, 0, ALL,
                           TextAttributesContainer.HORIZONTAL_GAP)

        return styleContainer
Ejemplo n.º 6
0
    def __createBooleanControls(self):
        """
        Creates the main control and stashes them as private instance variables
        """

        self.__cbMaximize: CheckBox = CheckBox(self, self.__maximizeID,
                                               _("&Full Screen on startup"))
        self.__cbAutoResize: CheckBox = CheckBox(
            self, self.__autoResizeID,
            _("&Auto resize classes to fit content"))
        self.__cbShowParams: CheckBox = CheckBox(self, self.__showParamsID,
                                                 _("&Show params in classes"))
        self.__cbShowTips: CheckBox = CheckBox(self, self.__showTipsID,
                                               _("Show &Tips on startup"))
        self.__cbCenterDiagram: CheckBox = CheckBox(self,
                                                    self.__centerDiagramID,
                                                    _('Center Diagram'))

        self.__btnResetTips: Button = Button(self, self.__resetTipsID,
                                             _('Reset Tips'))
Ejemplo n.º 7
0
    def _createControls(self):
        """
        Creates the main control and stashes them as private instance variables
        """

        self.__cbMaximize:        CheckBox = CheckBox(self, self.__maximizeID,        _('&Full Screen on startup'))
        self.__cbAutoResize:      CheckBox = CheckBox(self, self.__autoResizeID,      _('&Auto resize classes to fit content'))
        self.__cbShowParams:      CheckBox = CheckBox(self, self.__showParamsID,      _("&Show method parameters"))
        self.__cbShowTips:        CheckBox = CheckBox(self, self.__showTipsID,        _("Show &Tips on startup"))
        self.__cbCenterDiagram:   CheckBox = CheckBox(self, self.__centerDiagramID,   _('&Center Diagram View'))
        self.__cbToolBarIconSize: CheckBox = CheckBox(self, self.__toolBarIconSizeID, _('&Large Toolbar Icons'))

        self.__btnResetTips: Button = Button(self, self.__resetTipsID, _('Reset Tips'))

        mainSizer: BoxSizer = BoxSizer(VERTICAL)

        mainSizer.Add(self.__cbAutoResize,      0, ALL, GeneralPreferencesPanel.VERTICAL_GAP)
        mainSizer.Add(self.__cbShowParams,      0, ALL, GeneralPreferencesPanel.VERTICAL_GAP)
        mainSizer.Add(self.__cbMaximize,        0, ALL, GeneralPreferencesPanel.VERTICAL_GAP)
        mainSizer.Add(self.__cbCenterDiagram,   0, ALL, GeneralPreferencesPanel.VERTICAL_GAP)
        mainSizer.Add(self.__cbShowTips,        0, ALL, GeneralPreferencesPanel.VERTICAL_GAP)
        mainSizer.Add(self.__cbToolBarIconSize, 0, ALL, GeneralPreferencesPanel.VERTICAL_GAP)

        mainSizer.Add(self.__btnResetTips,   0, ALL, GeneralPreferencesPanel.VERTICAL_GAP)

        self.SetAutoLayout(True)
        self.SetSizer(mainSizer)

        self.Bind(EVT_CHECKBOX, self.__OnCheckBox, id=self.__autoResizeID)
        self.Bind(EVT_CHECKBOX, self.__OnCheckBox, id=self.__showParamsID)
        self.Bind(EVT_CHECKBOX, self.__OnCheckBox, id=self.__maximizeID)
        self.Bind(EVT_CHECKBOX, self.__OnCheckBox, id=self.__showTipsID)
        self.Bind(EVT_CHECKBOX, self.__OnCheckBox, id=self.__toolBarIconSizeID)

        self.Bind(EVT_BUTTON,   self.__OnBtnResetTips, id=self.__resetTipsID)
Ejemplo n.º 8
0
    def _makeACheckBox(self, valueToSet: bool, rowNumber: int, columnName: str,
                       columnIdx: int):

        nameInfo: str = self.__embedInformationInName(columnName=columnName,
                                                      rowNumber=rowNumber,
                                                      columnNumber=columnIdx)
        retCB: CheckBox = CheckBox(self,
                                   ID_ANY,
                                   "",
                                   DefaultPosition,
                                   DefaultSize,
                                   0,
                                   name=nameInfo)
        retCB.SetValue(valueToSet)
        retCB.Bind(EVT_CHECKBOX, self._onListItemChecked)

        self.SetItemWindow(rowNumber, columnIdx, retCB, expand=True)
Ejemplo n.º 9
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
Ejemplo n.º 10
0
 def field_from_value(self, window, value, field):
     item = None
     if isinstance(value, basestring):
         item = TextCtrl(window, value=value)
         field.text_type = STRING_SETTING
     elif isinstance(value, list):
         if isinstance(value[0], basestring):
             item = TextCtrl(window, value=", ".join(value))
             field.text_type = STRINGLIST_SETTING
         elif isinstance(value[0], int):
             item = TextCtrl(window,
                             value=", ".join((str(x) for x in value)))
             field.text_type = INTEGERLIST_SETTING
     elif isinstance(value, bool):
         item = CheckBox(window, -1, '', (120, 75))
         item.SetValue(value)
     elif isinstance(value, int):
         item = TextCtrl(window, value=str(value))
         field.text_type = INTEGER_SETTING
     elif isinstance(value, dict):
         subpage = Panel(window)
         vbox = BoxSizer(VERTICAL)
         alpha = value.keys()
         alpha.sort()
         for lbl in alpha:
             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
     field.wx_field = item
     return item
Ejemplo n.º 11
0
    def _buildLowerDialog(self) -> BoxSizer:

        nextTipButton: Button = Button(self, ID_SET_NEXT_TIP, _("&Next tip"))
        previousTipButton: Button = Button(self, ID_SET_PREVIOUS_TIP,
                                           _("&Previous tip"))

        loSizer: BoxSizer = BoxSizer(HORIZONTAL)

        loSizer.Add(previousTipButton, WX_SIZER_NOT_CHANGEABLE,
                    ALL | ALIGN_CENTER, 5)
        loSizer.Add(nextTipButton, WX_SIZER_NOT_CHANGEABLE, ALL | ALIGN_CENTER,
                    5)
        loSizer.Add(Button(self, ID_OK, "&Ok"), 0, ALL | ALIGN_CENTER, 5)

        self._chkShowTips: CheckBox = CheckBox(self, ID_CHK_SHOW_TIPS,
                                               _("&Show tips at startup"))

        showTips: bool = self._prefs.showTipsOnStartup
        self._chkShowTips.SetValue(showTips)

        return loSizer
Ejemplo n.º 12
0
 def construct_entry_control(self, entry):
     """Creates the primary entry control"""
     if 'boolean' == entry.var_type:
         control = CheckBox(
             self.scrolled_panel,
             name=entry.key_name
         )
         control.SetValue(entry.current)
     elif 'number' == entry.var_type:
         control = SpinCtrl(
             self.scrolled_panel,
             name=entry.key_name,
         )
         control.SetValue(entry.current)
     else:
         control = TextCtrl(
             self.scrolled_panel,
             value=str(entry.current),
             name=entry.key_name,
             size=(-1, -1)
         )
     self.grid_sizer.Add(control, -1, EXPAND)
Ejemplo n.º 13
0
    def __init__(self, *args, **kwargs):
        Panel.__init__(self, *args, **kwargs)
        sizer = GridBagSizer(5, 5)

        row = 0
        col = 0
        self.cb_html_output = CheckBox(self, label=u'Report in HTML')
        self.cb_html_output.Bind(EVT_CHECKBOX, self.__on_check)
        sizer.Add(self.cb_html_output,
                  pos=(row, col),
                  flag=FLAG_ALL_AND_EXPAND)

        col += 1
        self.txt_html_report = TextCtrl(self, style=TE_READONLY)
        self.txt_html_report.Disable()
        sizer.Add(self.txt_html_report,
                  pos=(row, col),
                  span=(1, 3),
                  flag=FLAG_ALL_AND_EXPAND)

        col += 3
        self.btn_select_html = Button(self, label=u'Select HTML file')
        self.btn_select_html.Disable()
        self.btn_select_html.Bind(EVT_BUTTON, self.__on_select_file)
        sizer.Add(self.btn_select_html,
                  pos=(row, col),
                  flag=FLAG_ALL_AND_EXPAND)

        row += 1
        col = 0
        self.cb_xml_output = CheckBox(self, label=u'Report in XML')
        self.cb_xml_output.Bind(EVT_CHECKBOX, self.__on_check)
        sizer.Add(self.cb_xml_output, pos=(row, col), flag=FLAG_ALL_AND_EXPAND)

        col += 1
        self.txt_xml_report = TextCtrl(self, style=TE_READONLY)
        self.txt_xml_report.Disable()
        sizer.Add(self.txt_xml_report,
                  pos=(row, col),
                  span=(1, 3),
                  flag=FLAG_ALL_AND_EXPAND)

        col += 3
        self.btn_select_xml = Button(self, label=u'Select XML file')
        self.btn_select_xml.Disable()
        self.btn_select_xml.Bind(EVT_BUTTON, self.__on_select_file)
        sizer.Add(self.btn_select_xml,
                  pos=(row, col),
                  flag=FLAG_ALL_AND_EXPAND)

        row += 1
        col = 0
        self.cb_options = CheckBox(self, label=u'Additional options')
        self.cb_options.Bind(EVT_CHECKBOX, self.__on_check)
        sizer.Add(self.cb_options, pos=(row, col), flag=FLAG_ALL_AND_EXPAND)

        col += 1
        self.txt_options = TextCtrl(self)
        self.txt_options.Disable()
        sizer.Add(self.txt_options,
                  pos=(row, col),
                  span=(1, 3),
                  flag=FLAG_ALL_AND_EXPAND)

        col += 3
        self.btn_nose_help = Button(self, label=u'Show help')
        self.btn_nose_help.Bind(EVT_BUTTON, self.__on_show_help)
        sizer.Add(self.btn_nose_help, pos=(row, col), flag=FLAG_ALL_AND_EXPAND)

        row += 1
        col = 0
        self.btn_load_tests_from_files = Button(self,
                                                label=u'Load tests from files')
        self.btn_load_tests_from_files.Bind(EVT_BUTTON,
                                            self.__load_tests_from_files)
        sizer.Add(self.btn_load_tests_from_files,
                  pos=(row, col),
                  flag=FLAG_ALL_AND_EXPAND)

        col += 1
        self.btn_load_tests_from_dir = Button(
            self, label=u'Load tests from directory')
        self.btn_load_tests_from_dir.Bind(EVT_BUTTON,
                                          self.__load_tests_from_directory)
        sizer.Add(self.btn_load_tests_from_dir,
                  pos=(row, col),
                  flag=FLAG_ALL_AND_EXPAND)

        col += 1
        dummy_label = StaticText(self)
        sizer.Add(dummy_label, pos=(row, col), flag=FLAG_ALL_AND_EXPAND)

        col += 1
        self.cb_browser = Choice(self,
                                 choices=Browser.get_supported_browsers())
        self.cb_browser.Select(0)
        sizer.Add(self.cb_browser, pos=(row, col), flag=FLAG_ALL_AND_EXPAND)

        col += 1
        self.btn_run = Button(self, label=u'Run test cases')
        self.btn_run.Bind(EVT_BUTTON, self.__run_tests)
        sizer.Add(self.btn_run, pos=(row, col), flag=FLAG_ALL_AND_EXPAND)

        row += 1
        col = 0
        window = SplitterWindow(self, style=SP_3D | SP_LIVE_UPDATE)
        self.tree_ctrl = CustomTreeCtrl(
            window,
            style=TR_SINGLE | TR_HAS_BUTTONS | TR_AUTO_CHECK_CHILD
            | TR_AUTO_CHECK_PARENT | TR_AUTO_TOGGLE_CHILD)
        self.tree_ctrl.SetBackgroundColour(self.GetBackgroundColour())
        self.tree_ctrl.SetForegroundColour(self.GetForegroundColour())
        self.tree_ctrl.Bind(EVT_TREE_ITEM_CHECKED, self.__on_tree_check)

        self.txt_ctrl = TextCtrl(window,
                                 style=TE_MULTILINE | TE_READONLY | HSCROLL
                                 | VSCROLL)
        font_size = self.txt_ctrl.GetFont().GetPointSize()
        self.txt_ctrl.SetFont(
            Font(font_size, FONTFAMILY_TELETYPE, NORMAL, NORMAL))

        window.SplitVertically(self.tree_ctrl, self.txt_ctrl)
        sizer.Add(window,
                  pos=(row, col),
                  span=(1, 5),
                  flag=FLAG_ALL_AND_EXPAND)

        sizer.AddGrowableCol(2, 1)
        sizer.AddGrowableRow(row, 1)
        self.SetSizerAndFit(sizer)
Ejemplo n.º 14
0
    def __init__(self, master, saveDirVal = None, backupDirVal = None):
        self.master = master

        saveDirSizer = BoxSizer(HORIZONTAL)
        self.saveDir = TextCtrl(master,
            size = (600, -1)
        )
        if saveDirVal:
            self.saveDir.SetValue(saveDirVal)
        saveDirSizer.Add(StaticText(master, label = "Save directory"), 0,
            EXPAND
        )
        saveDirSizer.Add(self.saveDir, 1, EXPAND)
        selectSaveDir = Button(master, -1, "Select")
        saveDirSizer.Add(selectSaveDir, 0, EXPAND)
        master.Bind(EVT_BUTTON, self._on_select_save_dir, selectSaveDir)
        openSave = Button(master, label = "Open")
        saveDirSizer.Add(openSave, 0, EXPAND)
        master.Bind(EVT_BUTTON, self._on_open_save_dir, openSave)
        hide = Button(master, label = "Hide")
        saveDirSizer.Add(hide, 0, EXPAND)
        master.Bind(EVT_BUTTON, self._on_hide, hide)

        backupDirSizer = BoxSizer(HORIZONTAL)
        self.backupDir = TextCtrl(master)
        if backupDirVal:
            self.backupDir.SetValue(backupDirVal)
        backupDirSizer.Add(StaticText(master, label = "Backup directory"), 0,
            EXPAND
        )
        backupDirSizer.Add(self.backupDir, 1, EXPAND)
        switch = Button(master, label = "Switch")
        master.Bind(EVT_BUTTON, self._on_switch, switch)
        backupDirSizer.Add(switch, 0, EXPAND)
        override = Button(master, label = "Overwrite")
        master.Bind(EVT_BUTTON, self._on_overwrite, override)
        backupDirSizer.Add(override, 0, EXPAND)
        selectBackupDir = Button(master, -1, "Select")
        master.Bind(EVT_BUTTON, self._on_select_backup_dir, selectBackupDir)
        backupDirSizer.Add(selectBackupDir, 0, EXPAND)
        openBackup = Button(master, label = "Open")
        backupDirSizer.Add(openBackup, 0, EXPAND)
        master.Bind(EVT_BUTTON, self._on_open_backup_dir, openBackup)

        filterOutSizer = BoxSizer(HORIZONTAL)
        filterOutSizer.Add(StaticText(master, label = "Filter Out"), 0, EXPAND)
        self.filterOut = TextCtrl(master)
        filterOutSizer.Add(self.filterOut, 1, EXPAND)

        self.cbMonitor = CheckBox(master, label = "Monitor")
        master.Bind(EVT_CHECKBOX, self._on_monitor, self.cbMonitor)

        self.sizer = sizer = BoxSizer(VERTICAL)
        sizer.Add(saveDirSizer, 0, EXPAND)
        sizer.Add(backupDirSizer, 0, EXPAND)
        sizer.Add(filterOutSizer, 0, EXPAND)
        sizer.Add(self.cbMonitor, 0, EXPAND)

        self.settingsWidgets = [
            selectSaveDir,
            self.saveDir,
            self.backupDir,
            switch,
            selectBackupDir,
            self.filterOut
        ]
Ejemplo n.º 15
0
    def __init__(self, parent):
        """
        """
        # Check
        import sys
        if sys.platform == "win32":
            return

        # Initialize the dialog box
        super().__init__(
            parent, -1, _("Tips"), DefaultPosition,
            Size(DEFAULT_WIDTH, DEFAULT_HEIGHT), RESIZE_BORDER | SYSTEM_MENU
            | CAPTION | FRAME_FLOAT_ON_PARENT | STAY_ON_TOP)

        # Normalize tips
        from org.pyut.general.LineSplitter import LineSplitter
        ls = LineSplitter()
        dc = ClientDC(self)
        for i in range(len(Tips)):
            tip = ls.split(Tips[i], dc, int(DEFAULT_WIDTH * 0.8))
            Tips[i] = ""
            for line in tip:
                Tips[i] += line + "\n"
            # tip = ""
            # for line in Tips[i].split("\n"):
            # newLine = ""
            # for word in line.split(" "):
            # if len(newLine) + len(word) > 59:
            # tip += newLine + "\n"
            # newLine = ""
            # newLine += word + " "
            # tip += newLine
            # Tips[i] = tip

        # Set current tips
        self._prefs = PyutPreferences()
        self._currentTip = self._prefs[PyutPreferences.CURRENT_TIP]
        if self._currentTip is None:
            self._currentTip = 0
        else:
            self._currentTip = int(self._currentTip)

        # Add icon
        # fileName = resource_filename(IMG_PKG, 'TipsLogo.bmp')
        # icon = Icon(fileName, BITMAP_TYPE_BMP)
        # self.SetIcon(icon)
        # self.Center(BOTH)                     # Center on the screen
        self.Center(dir=VERTICAL)
        self.AcceptsFocus()
        # Create controls
        # bmp: Bitmap = org.pyut.resources.img.ImgTipsFrameTipsLogo.embeddedImage.GetBitmap()
        bmp: Bitmap = TipsLogo.GetBitmap()
        self._picture = StaticBitmap(self, -1, bmp)
        tip = Tips[self._currentTip]
        self._label = StaticText(self,
                                 -1,
                                 tip,
                                 size=Size(DEFAULT_WIDTH * 0.8,
                                           DEFAULT_HEIGHT * 0.8),
                                 style=ST_NO_AUTORESIZE)

        nextTipButton = Button(self, ID_SET_NEXT_TIP, _("&Next tip"))
        previousTipButton = Button(self, ID_SET_PREVIOUS_TIP,
                                   _("&Previous tip"))
        self._chkShowTips = CheckBox(self, ID_CHK_SHOW_TIPS,
                                     _("&Show tips at startup"))
        showTips: bool = self._prefs.showTipsOnStartup()
        self._chkShowTips.SetValue(showTips)

        # Upper sizer
        upSizer = BoxSizer(HORIZONTAL)
        upSizer.Add(self._picture, 0, ALL | ALIGN_CENTER, 5)
        upSizer.Add(self._label, 1, ALL | ALIGN_CENTER, 5)

        # Lower sizer
        loSizer = BoxSizer(HORIZONTAL)
        loSizer.Add(previousTipButton, 0, ALL | ALIGN_CENTER, 5)
        loSizer.Add(nextTipButton, 0, ALL | ALIGN_CENTER, 5)
        loSizer.Add(Button(self, ID_OK, "&Ok"), 0, ALL | ALIGN_CENTER, 5)

        # Main sizer
        self.SetAutoLayout(True)
        mainSizer = BoxSizer(VERTICAL)
        mainSizer.Add(upSizer, 0, ALL | ALIGN_CENTER, 5)
        mainSizer.Add(self._chkShowTips, 0, ALL | ALIGN_CENTER, 5)
        mainSizer.Add(loSizer, 0, ALL | ALIGN_CENTER, 5)
        self.SetSizer(mainSizer)
        mainSizer.Fit(self)

        # Events
        self.Bind(EVT_BUTTON, self._onOk, id=ID_OK)
        self.Bind(EVT_CLOSE, self._onClose)
        self.Bind(EVT_BUTTON, self._onNextTip, id=ID_SET_NEXT_TIP)
        self.Bind(EVT_BUTTON, self._onPreviousTip, id=ID_SET_PREVIOUS_TIP)
Ejemplo n.º 16
0
    def __init__(self, parent, windowId, pyutClass: PyutClass):
        """

        Args:
            parent:         dialog parent
            windowId:       dialog identity
            pyutClass:      Class modified by dialog
        """
        super().__init__(parent=parent,
                         windowId=windowId,
                         dlgTitle=_("Class Edit"),
                         pyutModel=pyutClass)

        self.logger: Logger = getLogger(__name__)
        lblStereotype: StaticText = StaticText(self, -1, _("Stereotype"))
        self._txtStereotype: TextCtrl = TextCtrl(self,
                                                 ID_TXT_STEREO_TYPE,
                                                 "",
                                                 size=(125, -1))

        self._szrNameStereotype.Add(lblStereotype, 0, ALL, 5)
        self._szrNameStereotype.Add(self._txtStereotype, 1, ALIGN_CENTER)

        # Label Fields
        lblField = StaticText(self, -1, _("Fields :"))

        # ListBox List
        self._lstFieldList = ListBox(self,
                                     ID_LST_FIELD_LIST,
                                     choices=[],
                                     style=LB_SINGLE)
        self.Bind(EVT_LISTBOX, self._evtFieldList, id=ID_LST_FIELD_LIST)
        self.Bind(EVT_LISTBOX_DCLICK,
                  self._evtFieldListDClick,
                  id=ID_LST_FIELD_LIST)

        # Button Add
        self._btnFieldAdd = Button(self, ID_BTN_FIELD_ADD, _("&Add"))
        self.Bind(EVT_BUTTON, self._onFieldAdd, id=ID_BTN_FIELD_ADD)

        # Button Edit
        self._btnFieldEdit = Button(self, ID_BTN_FIELD_EDIT, _("&Edit"))
        self.Bind(EVT_BUTTON, self._onFieldEdit, id=ID_BTN_FIELD_EDIT)

        # Button Remove
        self._btnFieldRemove = Button(self, ID_BTN_FIELD_REMOVE, _("&Remove"))
        self.Bind(EVT_BUTTON, self._onFieldRemove, id=ID_BTN_FIELD_REMOVE)

        # Button Up
        self._btnFieldUp = Button(self, ID_BTN_FIELD_UP, _("&Up"))
        self.Bind(EVT_BUTTON, self._onFieldUp, id=ID_BTN_FIELD_UP)

        # Button Down
        self._btnFieldDown = Button(self, ID_BTN_FIELD_DOWN, _("&Down"))
        self.Bind(EVT_BUTTON, self._onFieldDown, id=ID_BTN_FIELD_DOWN)

        # Sizer for Fields buttons
        szrFieldButtons = BoxSizer(HORIZONTAL)
        szrFieldButtons.Add(self._btnFieldAdd, 0, ALL, 5)
        szrFieldButtons.Add(self._btnFieldEdit, 0, ALL, 5)
        szrFieldButtons.Add(self._btnFieldRemove, 0, ALL, 5)
        szrFieldButtons.Add(self._btnFieldUp, 0, ALL, 5)
        szrFieldButtons.Add(self._btnFieldDown, 0, ALL, 5)

        szrMethodButtons: BoxSizer = self._createMethodsUIArtifacts()
        # Show stereotype checkbox
        self._chkShowStereotype = CheckBox(self, -1, _("Show stereotype"))

        # Show fields checkbox
        self._chkShowFields = CheckBox(self, -1, _("Show fields"))

        # Show methods checkbox
        self._chkShowMethods = CheckBox(self, -1, _("Show methods"))

        # Sizer for display properties
        szrDisplayProperties = BoxSizer(VERTICAL)
        szrDisplayProperties.Add(self._chkShowStereotype, 0, ALL, 5)
        szrDisplayProperties.Add(self._chkShowFields, 0, ALL, 5)
        szrDisplayProperties.Add(self._chkShowMethods, 0, ALL, 5)

        self._szrMain.Add(lblField, 0, ALL, 5)
        self._szrMain.Add(self._lstFieldList, 1, ALL | EXPAND, 5)
        self._szrMain.Add(szrFieldButtons, 0, ALL | ALIGN_CENTER_HORIZONTAL, 5)

        self._szrMain.Add(self._lblMethod, 0, ALL, 5)
        self._szrMain.Add(self._lstMethodList, 1, ALL | EXPAND, 5)
        self._szrMain.Add(szrMethodButtons, 0, ALL | ALIGN_CENTER_HORIZONTAL,
                          5)

        self._szrMain.Add(szrDisplayProperties, 0,
                          ALL | ALIGN_CENTER_HORIZONTAL, 5)
        self._szrMain.Add(
            self._szrButtons, 0, ALL | ALIGN_RIGHT, 5
        )  # wxPython 4.1.0 Vertical alignment flags are ignored in vertical sizers

        # Fill the txt control with class data
        self._fillAllControls()

        # Fix buttons (enable or not)
        self._fixBtnFields()
        self._fixBtnMethod()

        # Set the focus and selection
        self._txtName.SetFocus()
        self._txtName.SetSelection(0, len(self._txtName.GetValue()))

        # Help Pycharm
        self._dlgMethod = cast(Dialog, None)
        self._szrMain.Fit(self)  # subclasses need to do this

        self.Centre()
        self.ShowModal()