def __init__(self, parent, label=None, style=DEFAULT_MANSECT_STYLE): ManSectBase.__init__(self, parent) self.Style = style if self.HasStyle((manid.CHOICE & manid.MUTABLE)): # FIXME: Raise exception Logger.Error(__name__, u'Cannot use CHOICE and MUTABLE styles together') return # Allow adding multiple instances of object # FIXME: Unused??? self.Multiple = True self.Panel = ManPanel(parent) if self.HasStyle(manid.CHOICE): self.Label = Choice(self.Panel) elif self.HasStyle(manid.MUTABLE): self.Label = ComboBox(self.Panel) else: self.Label = wx.StaticText(self.Panel) if label: self.Label.SetLabel(label) # *** Layout *** # self.lyt_main.Add(self.Label, -1, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.LEFT, 5) if style & manid.REMOVABLE: self.lyt_main.AddStretchSpacer(1) self.lyt_main.Add(CreateButton(self.Panel, btnid.REMOVE), 0, wx.TOP | wx.BOTTOM, 5) self.Panel.SetSizer(self.lyt_main)
class ManSectBase2(ManSectBase): def __init__(self, parent, label=None, style=DEFAULT_MANSECT_STYLE): ManSectBase.__init__(self, parent) self.Style = style if self.HasStyle((manid.CHOICE & manid.MUTABLE)): # FIXME: Raise exception Logger.Error(__name__, u'Cannot use CHOICE and MUTABLE styles together') return # Allow adding multiple instances of object # FIXME: Unused??? self.Multiple = True self.Panel = ManPanel(parent) if self.HasStyle(manid.CHOICE): self.Label = Choice(self.Panel) elif self.HasStyle(manid.MUTABLE): self.Label = ComboBox(self.Panel) else: self.Label = wx.StaticText(self.Panel) if label: self.Label.SetLabel(label) # *** Layout *** # self.lyt_main.Add(self.Label, -1, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.LEFT, 5) if style & manid.REMOVABLE: self.lyt_main.AddStretchSpacer(1) self.lyt_main.Add(CreateButton(self.Panel, btnid.REMOVE), 0, wx.TOP | wx.BOTTOM, 5) self.Panel.SetSizer(self.lyt_main) ## TODO: Doxygen def _add_field(self, label, window, count=1, expand=False): if isinstance(label, (unicode, str)): label = wx.StaticText(self.Parent, label=label) lyt_field = BoxSizer(wx.HORIZONTAL) for X in range(count): if expand: lyt_field.Add(window, 1, wx.EXPAND) continue lyt_field.Add(window, 1) self.lyt_main.Add(label, 0, wx.ALIGN_BOTTOM | wx.LEFT, 5) if expand: self.lyt_main.Add(lyt_field, 1, wx.EXPAND | wx.LEFT | wx.BOTTOM, 5) else: self.lyt_main.Add(lyt_field, 1, wx.LEFT | wx.BOTTOM, 5) self.Parent.Layout() ## Retrieves the section label or StaticText instance # # \param string # If \b \e True, retrieves string value, otherwise retrieves StaticText instance # \return # \b \e String or \b \e wx.StaticText instance def GetLabel(self, string=True): if string: label = self.Label.GetLabel() # DEBUG: Line print( u'\nDEBUG: ui.mansect.SingleLineSect.GetLabel: Label type: {}'. format(type(label))) return label return self.Label ## TODO: Doxygen def GetLabelObject(self): return self.GetLabel(False) ## Retrieve the main object def GetObject(self): return self.Panel ## Retrieve RemoveButton instance def GetButton(self): for FIELD in self.Panel.GetChildren(): if isinstance(FIELD, CustomButton) and FIELD.GetId() == btnid.REMOVE: return FIELD ## Retrieve styling used by instance def GetStyle(self): return self.Style ## Check if instance is using style def HasStyle(self, style): return self.Style & style ## Checks multiple instances can be uses def MultipleAllowed(self): return self.Multiple ## Sets the section label # # \param label # \b \e String value or wx.StaticText instance for new label def SetLabel(self, label): if isinstance(label, wx.StaticText): label = label.GetLabel() self.Label.SetLabel(label)
def __init__(self, ID=wx.ID_ANY): wx.Dialog.__init__(self, GetMainWindow(), ID) # User selector self.users = ComboBox(self)
def __init__(self, parent): WizardPage.__init__(self, parent, pgid.CHANGELOG) txt_package = wx.StaticText(self, label=GT(u'Package'), name=u'package') self.ti_package = TextArea(self, inputid.PACKAGE, name=txt_package.Name) txt_version = wx.StaticText(self, label=GT(u'Version'), name=u'version') self.ti_version = TextArea(self, inputid.VERSION, name=txt_version.Name) dist_names = GetOSDistNames() txt_dist = wx.StaticText(self, label=GT(u'Distribution'), name=u'dist') if dist_names: self.ti_dist = ComboBox(self, inputid.DIST, choices=dist_names, name=txt_dist.Name) # Use regular text input if could not retrieve distribution names list else: self.ti_dist = TextArea(self, inputid.DIST, name=txt_dist.Name) opts_urgency = ( u'low', u'medium', u'high', u'emergency', ) txt_urgency = wx.StaticText(self, label=GT(u'Urgency'), name=u'urgency') self.sel_urgency = Choice(self, selid.URGENCY, choices=opts_urgency, name=txt_urgency.Name) txt_maintainer = wx.StaticText(self, label=GT(u'Maintainer'), name=u'maintainer') self.ti_maintainer = TextArea(self, inputid.MAINTAINER, name=txt_maintainer.Name) txt_email = wx.StaticText(self, label=GT(u'Email'), name=u'email') self.ti_email = TextArea(self, inputid.EMAIL, name=txt_email.Name) btn_import = CreateButton(self, btnid.IMPORT, GT(u'Import'), u'import', name=u'btn import') txt_import = wx.StaticText( self, label=GT(u'Import information from Control page')) # Changes input self.ti_changes = TextAreaPanel(self, size=(20, 150), name=u'changes') # *** Target installation directory # FIXME: Should this be set by config or project file??? self.pnl_target = FileOTarget(self, u'/usr/share/doc/<package>', name=u'target default', defaultType=CheckBoxESS, customType=PathCtrlESS, pathIds=( chkid.TARGET, inputid.TARGET, )) self.btn_add = CreateButton(self, btnid.ADD, GT(u'Add'), u'add', name=u'btn add') txt_add = wx.StaticText(self, label=GT(u'Insert new changelog entry')) self.chk_indentation = CheckBox(self, label=GT(u'Preserve indentation'), name=u'indent') self.dsp_changes = TextAreaPanelESS(self, inputid.CHANGES, monospace=True, name=u'log') self.dsp_changes.EnableDropTarget() SetPageToolTips(self) # *** Event Handling *** # btn_import.Bind(wx.EVT_BUTTON, self.OnImportFromControl) self.btn_add.Bind(wx.EVT_BUTTON, self.AddInfo) # *** Layout *** # LEFT_BOTTOM = lyt.ALGN_LB LEFT_CENTER = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL RIGHT_CENTER = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL lyt_info = wx.FlexGridSizer(2, 6) lyt_info.AddGrowableCol(1) lyt_info.AddGrowableCol(3) lyt_info.AddGrowableCol(5) lyt_info.AddMany( ((txt_package, 0, RIGHT_CENTER | wx.RIGHT, 5), (self.ti_package, 1, wx.EXPAND | wx.BOTTOM | wx.RIGHT, 5), (txt_version, 0, RIGHT_CENTER | wx.RIGHT, 5), (self.ti_version, 1, wx.EXPAND | wx.BOTTOM | wx.RIGHT, 5), (txt_dist, 0, RIGHT_CENTER | wx.RIGHT, 5), (self.ti_dist, 1, wx.EXPAND | wx.BOTTOM, 5), (txt_urgency, 0, RIGHT_CENTER | wx.RIGHT, 5), (self.sel_urgency, 1, wx.RIGHT, 5), (txt_maintainer, 0, RIGHT_CENTER | wx.RIGHT, 5), (self.ti_maintainer, 1, wx.EXPAND | wx.RIGHT, 5), (txt_email, 0, RIGHT_CENTER | wx.RIGHT, 5), (self.ti_email, 1, wx.EXPAND))) lyt_details = wx.GridBagSizer() lyt_details.SetCols(3) lyt_details.AddGrowableRow(2) lyt_details.AddGrowableCol(1) lyt_details.Add(btn_import, (0, 0)) lyt_details.Add(txt_import, (0, 1), flag=LEFT_CENTER) lyt_details.Add(wx.StaticText(self, label=GT(u'Changes')), (1, 0), flag=LEFT_BOTTOM) lyt_details.Add(wx.StaticText(self, label=GT(u'Target')), (1, 2), flag=LEFT_BOTTOM) lyt_details.Add(self.ti_changes, (2, 0), (1, 2), wx.EXPAND | wx.RIGHT, 5) lyt_details.Add(self.pnl_target, (2, 2)) lyt_details.Add(self.btn_add, (3, 0), (2, 1)) lyt_details.Add(txt_add, (3, 1), flag=LEFT_BOTTOM | wx.TOP, border=5) lyt_details.Add(self.chk_indentation, (4, 1), flag=LEFT_BOTTOM) lyt_main = BoxSizer(wx.VERTICAL) lyt_main.AddSpacer(10) lyt_main.Add(lyt_info, 0, wx.EXPAND | lyt.PAD_LR, 5) lyt_main.AddSpacer(10) lyt_main.Add(lyt_details, 1, wx.EXPAND | lyt.PAD_LR, 5) lyt_main.Add(wx.StaticText(self, label=u'Changelog Output'), 0, LEFT_BOTTOM | lyt.PAD_LT, 5) lyt_main.Add(self.dsp_changes, 1, wx.EXPAND | lyt.PAD_LR | wx.BOTTOM, 5) self.SetAutoLayout(True) self.SetSizer(lyt_main) self.Layout()
def __init__(self, parent): WizardPage.__init__(self, parent, pgid.MENU) #, name=GT(u'Menu Launcher')) ## Override default label self.Label = GT(u'Menu Launcher') # --- Buttons to open/preview/save .desktop file btn_open = CreateButton(self, btnid.BROWSE, GT(u'Browse'), u'browse', name=u'btn browse') btn_save = CreateButton(self, btnid.SAVE, GT(u'Save'), u'save', name=u'btn save') btn_preview = CreateButton(self, btnid.PREVIEW, GT(u'Preview'), u'preview', name=u'btn preview') # --- CHECKBOX chk_enable = CheckBox(self, chkid.ENABLE, GT(u'Create system menu launcher')) # --- TYPE opts_type = ( u'Application', u'Link', u'Directory', ) txt_type = wx.StaticText(self, label=GT(u'Type'), name=u'type') ti_type = ComboBoxESS(self, inputid.TYPE, choices=opts_type, name=u'Type', defaultValue=opts_type[0]) # --- ENCODING opts_enc = ( u'UTF-1', u'UTF-7', u'UTF-8', u'CESU-8', u'UTF-EBCDIC', u'UTF-16', u'UTF-32', u'SCSU', u'BOCU-1', u'Punycode', u'GB 18030', ) txt_enc = wx.StaticText(self, label=GT(u'Encoding'), name=u'encoding') ti_enc = ComboBoxESS(self, inputid.ENC, choices=opts_enc, name=u'Encoding', defaultValue=opts_enc[2]) # --- TERMINAL chk_term = CheckBoxESS(self, chkid.TERM, GT(u'Terminal'), name=u'Terminal') # --- STARTUP NOTIFY chk_notify = CheckBoxESS(self, chkid.NOTIFY, GT(u'Startup Notify'), name=u'StartupNotify', defaultValue=True) # --- Custom output filename txt_filename = wx.StaticText(self, txtid.FNAME, GT(u'Filename'), name=u'filename') ti_filename = TextArea(self, inputid.FNAME, name=txt_filename.Name) chk_filename = CheckBox( self, chkid.FNAME, GT(u'Use "Name" as output filename (<Name>.desktop)'), name=u'filename chk', defaultValue=True) # --- NAME (menu) txt_name = wx.StaticText(self, label=GT(u'Name'), name=u'name*') ti_name = TextAreaESS(self, inputid.NAME, name=u'Name') ti_name.req = True # --- EXECUTABLE txt_exec = wx.StaticText(self, label=GT(u'Executable'), name=u'exec') ti_exec = TextAreaESS(self, inputid.EXEC, name=u'Exec') # --- COMMENT txt_comm = wx.StaticText(self, label=GT(u'Comment'), name=u'comment') ti_comm = TextAreaESS(self, inputid.DESCR, name=u'Comment') # --- ICON txt_icon = wx.StaticText(self, label=GT(u'Icon'), name=u'icon') ti_icon = TextAreaESS(self, inputid.ICON, name=u'Icon') txt_mime = wx.StaticText(self, label=GT(u'MIME Type'), name=u'mime') ti_mime = TextAreaESS(self, inputid.MIME, defaultValue=wx.EmptyString, name=u'MimeType') # ----- OTHER/CUSTOM txt_other = wx.StaticText(self, label=GT(u'Custom Fields'), name=u'other') ti_other = TextAreaPanel(self, inputid.OTHER, name=txt_other.Name) ti_other.EnableDropTarget() # --- CATEGORIES opts_category = ( u'2DGraphics', u'Accessibility', u'Application', u'ArcadeGame', u'Archiving', u'Audio', u'AudioVideo', u'BlocksGame', u'BoardGame', u'Calculator', u'Calendar', u'CardGame', u'Compression', u'ContactManagement', u'Core', u'DesktopSettings', u'Development', u'Dictionary', u'DiscBurning', u'Documentation', u'Email', u'FileManager', u'FileTransfer', u'Game', u'GNOME', u'Graphics', u'GTK', u'HardwareSettings', u'InstantMessaging', u'KDE', u'LogicGame', u'Math', u'Monitor', u'Network', u'OCR', u'Office', u'P2P', u'PackageManager', u'Photography', u'Player', u'Presentation', u'Printing', u'Qt', u'RasterGraphics', u'Recorder', u'RemoteAccess', u'Scanning', u'Screensaver', u'Security', u'Settings', u'Spreadsheet', u'System', u'Telephony', u'TerminalEmulator', u'TextEditor', u'Utility', u'VectorGraphics', u'Video', u'Viewer', u'WordProcessor', u'Wine', u'Wine-Programs-Accessories', u'X-GNOME-NetworkSettings', u'X-GNOME-PersonalSettings', u'X-GNOME-SystemSettings', u'X-KDE-More', u'X-Red-Hat-Base', u'X-SuSE-ControlCenter-System', ) txt_category = wx.StaticText(self, label=GT(u'Categories'), name=u'category') # This option does not get set by importing a new project ti_category = ComboBox(self, inputid.CAT, choices=opts_category, name=txt_category.Name, defaultValue=opts_category[0]) btn_catadd = CreateButton(self, btnid.ADD, GT(u'Add'), u'add', name=u'add category') btn_catdel = CreateButton(self, btnid.REMOVE, GT(u'Remove'), u'remove', name=u'rm category') btn_catclr = CreateButton(self, btnid.CLEAR, GT(u'Clear'), u'clear', name=u'clear category') # FIXME: Allow using multi-select + remove lst_categories = ListCtrl(self, listid.CAT, name=u'Categories') # Can't set LC_SINGLE_SEL in constructor for wx 3.0 (ListCtrl bug???) lst_categories.SetSingleStyle(wx.LC_SINGLE_SEL) self.OnToggle() SetPageToolTips(self) # *** Event Handling *** # btn_open.Bind(wx.EVT_BUTTON, self.OnLoadLauncher) btn_save.Bind(wx.EVT_BUTTON, self.OnExportLauncher) btn_preview.Bind(wx.EVT_BUTTON, self.OnPreviewLauncher) chk_enable.Bind(wx.EVT_CHECKBOX, self.OnToggle) chk_filename.Bind(wx.EVT_CHECKBOX, self.OnSetCustomFilename) wx.EVT_KEY_DOWN(ti_category, self.SetCategory) wx.EVT_KEY_DOWN(lst_categories, self.SetCategory) btn_catadd.Bind(wx.EVT_BUTTON, self.SetCategory) btn_catdel.Bind(wx.EVT_BUTTON, self.SetCategory) btn_catclr.Bind(wx.EVT_BUTTON, self.OnClearCategories) # *** Layout *** # LEFT_CENTER = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL LEFT_BOTTOM = lyt.ALGN_LB RIGHT_BOTTOM = wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM lyt_top = BoxSizer(wx.HORIZONTAL) lyt_top.Add(chk_enable, 0, LEFT_BOTTOM) lyt_top.AddStretchSpacer(1) lyt_top.Add(btn_open, 0, wx.ALIGN_TOP) lyt_top.Add(btn_save, 0, wx.ALIGN_TOP) lyt_top.Add(btn_preview, 0, wx.ALIGN_TOP) lyt_opts1 = wx.FlexGridSizer() lyt_opts1.SetCols(3) lyt_opts1.SetRows(2) lyt_opts1.Add(txt_type, 0, LEFT_CENTER) lyt_opts1.Add(ti_type, 0, wx.EXPAND | wx.LEFT, 5) lyt_opts1.Add(chk_term, 0, LEFT_CENTER | wx.LEFT, 5) lyt_opts1.Add(txt_enc, 0, LEFT_CENTER | wx.TOP, 5) lyt_opts1.Add(ti_enc, 0, lyt.PAD_LT, 5) lyt_opts1.Add(chk_notify, 0, LEFT_CENTER | lyt.PAD_LT, 5) lyt_mid = wx.GridBagSizer() lyt_mid.SetCols(4) lyt_mid.AddGrowableCol(1) lyt_mid.AddGrowableCol(3) # Row 1 row = 0 lyt_mid.Add(txt_filename, (row, 0), flag=LEFT_CENTER) lyt_mid.Add(ti_filename, (row, 1), flag=wx.EXPAND | wx.LEFT, border=5) lyt_mid.Add(chk_filename, (row, 2), span=(1, 2), flag=LEFT_CENTER | wx.LEFT, border=5) # Row 2 row += 1 lyt_mid.Add(txt_name, (row, 0), flag=LEFT_CENTER | wx.TOP, border=5) lyt_mid.Add(ti_name, (row, 1), flag=wx.EXPAND | lyt.PAD_LT, border=5) lyt_mid.Add(txt_exec, (row, 2), flag=LEFT_CENTER | lyt.PAD_LT, border=5) lyt_mid.Add(ti_exec, (row, 3), flag=wx.EXPAND | lyt.PAD_LT, border=5) # Row 3 row += 1 lyt_mid.Add(txt_comm, (row, 0), flag=LEFT_CENTER | wx.TOP, border=5) lyt_mid.Add(ti_comm, (row, 1), flag=wx.EXPAND | lyt.PAD_LT, border=5) lyt_mid.Add(txt_icon, (row, 2), flag=LEFT_CENTER | lyt.PAD_LT, border=5) lyt_mid.Add(ti_icon, (row, 3), flag=wx.EXPAND | lyt.PAD_LT, border=5) # Row 4 row += 1 lyt_mid.Add(txt_mime, (row, 0), flag=LEFT_CENTER | wx.TOP, border=5) lyt_mid.Add(ti_mime, (row, 1), flag=wx.EXPAND | lyt.PAD_LT, border=5) lyt_bottom = wx.GridBagSizer() row = 0 lyt_bottom.Add(txt_other, (row, 0), flag=LEFT_BOTTOM) lyt_bottom.Add(txt_category, (row, 2), flag=LEFT_BOTTOM | wx.LEFT, border=5) lyt_bottom.Add(ti_category, (row, 3), flag=LEFT_BOTTOM | wx.LEFT, border=5) lyt_bottom.Add(btn_catadd, (row, 4), flag=RIGHT_BOTTOM) lyt_bottom.Add(btn_catdel, (row, 5), flag=RIGHT_BOTTOM) lyt_bottom.Add(btn_catclr, (row, 6), flag=RIGHT_BOTTOM) row += 1 lyt_bottom.Add(ti_other, (row, 0), (1, 2), wx.EXPAND) lyt_bottom.Add(lst_categories, (row, 2), (1, 5), wx.EXPAND | wx.LEFT, 5) lyt_bottom.AddGrowableRow(1) lyt_bottom.AddGrowableCol(1) lyt_bottom.AddGrowableCol(4) # --- Page 5 Sizer --- # lyt_main = BoxSizer(wx.VERTICAL) lyt_main.AddSpacer(5) lyt_main.Add(lyt_top, 0, wx.EXPAND | lyt.PAD_LR, 5) lyt_main.Add(lyt_opts1, 0, wx.EXPAND | lyt.PAD_LRT, 5) lyt_main.Add(lyt_mid, 0, wx.EXPAND | lyt.PAD_LRT, 5) lyt_main.Add(lyt_bottom, 1, wx.EXPAND | wx.ALL, 5) self.SetAutoLayout(True) self.SetSizer(lyt_main) self.Layout()