def __init__(self, parent, scriptId): wx.Panel.__init__(self, parent, scriptId) ## Filename used for exporting script self.FileName = id_definitions[scriptId].lower() ## String name used for display in the application self.ScriptName = None self.SetScriptName() shell_options = [] shell_options.append(u'/bin/sh') # Place /bin/sh as first item for P in u'/bin/', u'/usr/bin/', u'/usr/bin/env ': for S in sorted(shell_descriptions, key=GS.lower): if S == u'sh': pass else: shell_options.append(P + S) self.Shell = ComboBoxESS(self, self.GetId(), choices=shell_options, monospace=True, defaultValue=u'/bin/bash') self.ScriptBody = TextAreaPanelESS(self, self.GetId(), monospace=True) self.ScriptBody.EnableDropTarget() # *** Layout *** # lyt_shell = BoxSizer(wx.HORIZONTAL) lyt_shell.Add(wx.StaticText(self, label=u'#!'), 0, lyt.ALGN_CV | wx.RIGHT, 5) lyt_shell.Add(self.Shell, 1) lyt_main = BoxSizer(wx.VERTICAL) lyt_main.Add(lyt_shell, 0) lyt_main.Add(self.ScriptBody, 1, wx.EXPAND | wx.TOP, 5) self.SetSizer(lyt_main) self.SetAutoLayout(True) self.Layout() # Scripts are hidden by default self.Hide()
class DebianScript(wx.Panel): ## Constructor # # \param parent # The <b><i>wx.Window</i></b> parent instance # \param scriptId # Unique <b><i>integer</i></b> identifier for script def __init__(self, parent, scriptId): wx.Panel.__init__(self, parent, scriptId) ## Filename used for exporting script self.FileName = id_definitions[scriptId].lower() ## String name used for display in the application self.ScriptName = None self.SetScriptName() shell_options = [] shell_options.append(u'/bin/sh') # Place /bin/sh as first item for P in u'/bin/', u'/usr/bin/', u'/usr/bin/env ': for S in sorted(shell_descriptions, key=GS.lower): if S == u'sh': pass else: shell_options.append(P + S) self.Shell = ComboBoxESS(self, self.GetId(), choices=shell_options, monospace=True, defaultValue=u'/bin/bash') self.ScriptBody = TextAreaPanelESS(self, self.GetId(), monospace=True) self.ScriptBody.EnableDropTarget() # *** Layout *** # lyt_shell = BoxSizer(wx.HORIZONTAL) lyt_shell.Add(wx.StaticText(self, label=u'#!'), 0, lyt.ALGN_CV|wx.RIGHT, 5) lyt_shell.Add(self.Shell, 1) lyt_main = BoxSizer(wx.VERTICAL) lyt_main.Add(lyt_shell, 0) lyt_main.Add(self.ScriptBody, 1, wx.EXPAND|wx.TOP, 5) self.SetSizer(lyt_main) self.SetAutoLayout(True) self.Layout() # Scripts are hidden by default self.Hide() ## Exports the script to a text file # # \param out_dir # Target directory of output file # \param executable # If <b><i>True</i></b>, sets the files executable bit # \param build # If <b><i>True</i></b>, format output for final build def Export(self, out_dir, executable=True, build=False): if not os.path.isdir(out_dir): Logger.Error(__name__, GT(u'Directory not available: {}'.format(out_dir))) return (ERR_DIR_NOT_AVAILABLE, __name__) if build: absolute_filename = ConcatPaths((out_dir, self.FileName)) else: filename = u'{}-{}'.format(page_ids[self.Parent.GetId()].upper(), self.FileName) absolute_filename = ConcatPaths((out_dir, filename)) script_text = u'{}\n\n{}'.format(self.GetShebang(), self.ScriptBody.GetValue()) WriteFile(absolute_filename, script_text) if not os.path.isfile(absolute_filename): Logger.Error(__name__, GT(u'Could not write to file: {}'.format(absolute_filename))) return (ERR_FILE_WRITE, __name__) if executable: os.chmod(absolute_filename, 0755) return (0, None) ## Retrieves the filename to use for exporting # # \return # Script filename def GetFilename(self): return self.FileName ## Retrieves the script's name for display # # \return # <b><i>String</i></b> representation of script's name def GetName(self): return self.ScriptName ## Retrieves the description of a shell for display # # \return # Description or <b><i>None</i></b> if using custom shell def GetSelectedShellDescription(self): selected_shell = self.Shell.GetValue() if selected_shell in shell_descriptions: return shell_descriptions[selected_shell] return None ## Retrieves the shebang/shell line def GetShebang(self): shell = self.Shell.GetValue() if shell.startswith(u'/usr/bin/env '): shell = u'#!{}\nset -e'.format(shell) else: shell = u'#!{} -e'.format(shell) return shell ## Retrieves the text body of the script def GetValue(self): return self.ScriptBody.GetValue() ## Checks if the script is used & can be exported # # The text area is checked &, if not empty, signifies that # the user want to export the script. # # \return # <b><i>True</i></b> if text area is not empty, <b><i>False</i></b> otherwise def IsOkay(self): return not TextIsEmpty(self.ScriptBody.GetValue()) ## Resets all members to default values def Reset(self): self.Shell.SetStringSelection(self.Shell.GetDefaultValue()) self.ScriptBody.Clear() ## Sets the name of the script to be displayed # # Sets the displayed script name to a value of either 'Pre Install', # 'Pre Uninstall', 'Post Install', or 'Post Uninstall'. 'self.FileName' # is used to determine the displayed name. # TODO: Add strings to GetText translations def SetScriptName(self): prefix = None suffix = None if u'pre' in self.FileName: prefix = u'Pre' suffix = self.FileName.split(u'pre')[1] elif u'post' in self.FileName: prefix = u'Post' suffix = self.FileName.split(u'post')[1] if suffix.lower() == u'inst': suffix = u'Install' elif suffix.lower() == u'rm': suffix = u'Uninstall' if (prefix != None) and (suffix != None): self.ScriptName = GT(u'{}-{}'.format(prefix, suffix)) ## Sets the shell/shebang line to use for script # # \param shell # Path to desired shell # \param forced # ??? def SetShell(self, shell, forced=False): if forced: self.Shell.SetValue(shell) return self.Shell.SetStringSelection(shell) ## Fills the script # # \param value # Text to be entered into the script body def SetValue(self, value): self.ScriptBody.SetValue(value)
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()
def __init__(self, parent): WizardPage.__init__(self, parent, pgid.CONTROL) # Bypass checking this page for build # This is mandatory & done manually self.prebuild_check = False self.SetScrollbars(0, 20, 0, 0) pnl_bg = wx.Panel(self) # Buttons to open, save, & preview control file btn_open = CreateButton(pnl_bg, btnid.BROWSE, GT(u'Browse'), u'browse', name=u'btn browse') btn_save = CreateButton(pnl_bg, btnid.SAVE, GT(u'Save'), u'save', name=u'btn save') btn_preview = CreateButton(pnl_bg, btnid.PREVIEW, GT(u'Preview'), u'preview', name=u'btn preview') # *** Required fields *** # pnl_require = BorderedPanel(pnl_bg) txt_package = wx.StaticText(pnl_require, label=GT(u'Package'), name=u'package') txt_package.req = True ti_package = TextAreaESS(pnl_require, inputid.PACKAGE, name=txt_package.Name) ti_package.req = True txt_version = wx.StaticText(pnl_require, label=GT(u'Version'), name=u'version') txt_version.req = True ti_version = TextAreaESS(pnl_require, inputid.VERSION, name=txt_version.Name) ti_version.req = True txt_maintainer = wx.StaticText(pnl_require, label=GT(u'Maintainer'), name=u'maintainer') txt_maintainer.req = True ti_maintainer = TextAreaESS(pnl_require, inputid.MAINTAINER, name=txt_maintainer.Name) ti_maintainer.req = True txt_email = wx.StaticText(pnl_require, label=GT(u'Email'), name=u'email') txt_email.req = True ti_email = TextAreaESS(pnl_require, inputid.EMAIL, name=txt_email.Name) ti_email.req = True opts_arch = ( u'all', u'alpha', u'amd64', u'arm', u'arm64', u'armeb', u'armel', u'armhf', u'avr32', u'hppa', u'i386', u'ia64', u'lpia', u'm32r', u'm68k', u'mips', u'mipsel', u'powerpc', u'powerpcspe', u'ppc64', u's390', u's390x', u'sh3', u'sh3eb', u'sh4', u'sh4eb', u'sparc', u'sparc64', ) txt_arch = wx.StaticText(pnl_require, label=GT(u'Architecture'), name=u'architecture') sel_arch = ChoiceESS(pnl_require, inputid.ARCH, choices=opts_arch, name=txt_arch.Name) sel_arch.Default = 0 sel_arch.SetSelection(sel_arch.Default) # *** Recommended fields *** # pnl_recommend = BorderedPanel(pnl_bg) opts_section = ( u'admin', u'cli-mono', u'comm', u'database', u'devel', u'debug', u'doc', u'editors', u'electronics', u'embedded', u'fonts', u'games', u'gnome', u'graphics', u'gnu-r', u'gnustep', u'hamradio', u'haskell', u'httpd', u'interpreters', u'java', u'kde', u'kernel', u'libs', u'libdevel', u'lisp', u'localization', u'mail', u'math', u'metapackages', u'misc', u'net', u'news', u'ocaml', u'oldlibs', u'otherosfs', u'perl', u'php', u'python', u'ruby', u'science', u'shells', u'sound', u'tex', u'text', u'utils', u'vcs', u'video', u'web', u'x11', u'xfce', u'zope', ) txt_section = wx.StaticText(pnl_recommend, label=GT(u'Section'), name=u'section') ti_section = ComboBoxESS(pnl_recommend, choices=opts_section, name=txt_section.Name) opts_priority = ( u'optional', u'standard', u'important', u'required', u'extra', ) txt_priority = wx.StaticText(pnl_recommend, label=GT(u'Priority'), name=u'priority') sel_priority = ChoiceESS(pnl_recommend, choices=opts_priority, name=txt_priority.Name) sel_priority.Default = 0 sel_priority.SetSelection(sel_priority.Default) txt_synopsis = wx.StaticText(pnl_recommend, label=GT(u'Short Description'), name=u'synopsis') ti_synopsis = TextAreaESS(pnl_recommend, name=txt_synopsis.Name) txt_description = wx.StaticText(pnl_recommend, label=GT(u'Long Description'), name=u'description') self.ti_description = TextAreaPanelESS(pnl_recommend, name=txt_description.Name) # *** Optional fields *** # pnl_option = BorderedPanel(pnl_bg) txt_source = wx.StaticText(pnl_option, label=GT(u'Source'), name=u'source') ti_source = TextAreaESS(pnl_option, name=txt_source.Name) txt_homepage = wx.StaticText(pnl_option, label=GT(u'Homepage'), name=u'homepage') ti_homepage = TextAreaESS(pnl_option, name=txt_homepage.Name) txt_essential = wx.StaticText(pnl_option, label=GT(u'Essential'), name=u'essential') self.chk_essential = CheckBoxESS(pnl_option, name=u'essential') self.chk_essential.Default = False self.grp_input = ( ti_package, ti_version, ti_maintainer, # Maintainer must be listed before email ti_email, ti_section, ti_source, ti_homepage, ti_synopsis, self.ti_description, ) self.grp_select = ( sel_arch, sel_priority, ) SetPageToolTips(self) # *** Event Handling *** # btn_open.Bind(wx.EVT_BUTTON, self.OnBrowse) btn_save.Bind(wx.EVT_BUTTON, self.OnSave) btn_preview.Bind(wx.EVT_BUTTON, self.OnPreviewControl) # *** Layout *** # LEFT_BOTTOM = lyt.ALGN_LB RIGHT_CENTER = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT # Buttons lyt_buttons = BoxSizer(wx.HORIZONTAL) lyt_buttons.Add(btn_open, 0) lyt_buttons.Add(btn_save, 0) lyt_buttons.Add(btn_preview, 0) # Required fields lyt_require = wx.FlexGridSizer(0, 4, 5, 5) lyt_require.AddGrowableCol(1) lyt_require.AddGrowableCol(3) lyt_require.AddMany(( (txt_package, 0, RIGHT_CENTER | lyt.PAD_LT, 5), (ti_package, 0, wx.EXPAND | wx.TOP, 5), (txt_version, 0, RIGHT_CENTER | wx.TOP, 5), (ti_version, 0, wx.EXPAND | wx.TOP | wx.RIGHT, 5), (txt_maintainer, 0, RIGHT_CENTER | wx.LEFT, 5), (ti_maintainer, 0, wx.EXPAND), (txt_email, 0, RIGHT_CENTER, 5), (ti_email, 0, wx.EXPAND | wx.RIGHT, 5), (txt_arch, 0, RIGHT_CENTER | lyt.PAD_LB, 5), (sel_arch, 0, wx.BOTTOM, 5), )) pnl_require.SetSizer(lyt_require) pnl_require.SetAutoLayout(True) pnl_require.Layout() # Recommended fields lyt_recommend = wx.GridBagSizer() lyt_recommend.SetCols(4) lyt_recommend.AddGrowableCol(1) lyt_recommend.AddGrowableRow(3) lyt_recommend.Add(txt_section, (0, 2), flag=RIGHT_CENTER | lyt.PAD_TB, border=5) lyt_recommend.Add(ti_section, (0, 3), flag=wx.EXPAND | lyt.PAD_RTB, border=5) lyt_recommend.Add(txt_synopsis, (0, 0), (1, 2), LEFT_BOTTOM | wx.LEFT, 5) lyt_recommend.Add(ti_synopsis, (1, 0), (1, 2), wx.EXPAND | lyt.PAD_LR, 5) lyt_recommend.Add(txt_priority, (1, 2), flag=RIGHT_CENTER, border=5) lyt_recommend.Add(sel_priority, (1, 3), flag=wx.EXPAND | wx.RIGHT, border=5) lyt_recommend.Add(txt_description, (2, 0), (1, 2), LEFT_BOTTOM | lyt.PAD_LT, 5) lyt_recommend.Add(self.ti_description, (3, 0), (1, 4), wx.EXPAND | lyt.PAD_LR | wx.BOTTOM, 5) pnl_recommend.SetSizer(lyt_recommend) pnl_recommend.SetAutoLayout(True) pnl_recommend.Layout() # Optional fields lyt_option = wx.FlexGridSizer(0, 4, 5, 5) lyt_option.AddGrowableCol(1) lyt_option.AddGrowableCol(3) lyt_option.AddSpacer(5) lyt_option.AddSpacer(5) lyt_option.AddSpacer(5) lyt_option.AddSpacer(5) lyt_option.AddMany(( (txt_source, 0, RIGHT_CENTER | wx.LEFT, 5), (ti_source, 0, wx.EXPAND), (txt_homepage, 0, RIGHT_CENTER, 5), (ti_homepage, 0, wx.EXPAND | wx.RIGHT, 5), (txt_essential, 0, RIGHT_CENTER | lyt.PAD_LB, 5), (self.chk_essential, 0, wx.BOTTOM, 5), )) pnl_option.SetSizer(lyt_option) pnl_option.SetAutoLayout(True) pnl_option.Layout() # Main background panel sizer # FIXME: Is background panel (pnl_bg) necessary lyt_bg = BoxSizer(wx.VERTICAL) lyt_bg.Add(lyt_buttons, 0, wx.ALIGN_RIGHT | wx.BOTTOM, 5) lyt_bg.Add(wx.StaticText(pnl_bg, label=GT(u'Required')), 0) lyt_bg.Add(pnl_require, 0, wx.EXPAND) lyt_bg.Add(wx.StaticText(pnl_bg, label=GT(u'Recommended')), 0, wx.TOP, 5) lyt_bg.Add(pnl_recommend, 1, wx.EXPAND) lyt_bg.Add(wx.StaticText(pnl_bg, label=GT(u'Optional')), 0, wx.TOP, 5) lyt_bg.Add(pnl_option, 0, wx.EXPAND) pnl_bg.SetAutoLayout(True) pnl_bg.SetSizer(lyt_bg) pnl_bg.Layout() # Page's main sizer lyt_main = BoxSizer(wx.VERTICAL) lyt_main.AddSpacer(5) lyt_main.Add(pnl_bg, 1, wx.EXPAND | lyt.PAD_LR | wx.BOTTOM, 5) self.SetAutoLayout(True) self.SetSizer(lyt_main) self.Layout()
def __init__(self, parent, win_id=wx.ID_ANY, name=u'launcher'): ScrolledPanel.__init__(self, parent, win_id, name=name) # --- 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') # --- 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) # --- 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', outLabel=u'MimeType') # ----- OTHER/CUSTOM txt_other = wx.StaticText(self, label=GT(u'Custom Fields'), name=u'other') btn_other = CreateButton(self, label=GT(u'Other'), image=u'add', name=u'btn other') btn_rm_other = CreateButton(self, btnid.REMOVE, GT(u'Remove Other'), u'remove', name=u'btn rm other') pnl_other = SectionedPanel(self, inputid.OTHER) btn_rm_other.Enable(pnl_other.HasSelected()) # --- 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') btn_catclr = CreateButton(self, btnid.CLEAR, GT(u'Clear'), u'clear', name=u'clear category') lst_categories = CheckList(self, listid.CAT, opts_category, name=u'Categories') if not lst_categories.HasSelected(): btn_catclr.Disable() txt_catcustom = wx.StaticText( self, label=GT(u'Custom Categories (Separate by "," or ";")')) # Set to 'True' to list custom categories first # FIXME: Should this be saved to project instead of config??? chk_catcustom = CheckBoxCFG(self, chkid.CAT, GT(u'List first'), name=u'chk catcustom', cfgKey=u'prioritize custom categories') ti_catcustom = TextAreaESS(self, inputid.CAT2, name=u'category custom') # *** 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) btn_other.Bind(wx.EVT_BUTTON, self.OnOtherAdd) btn_rm_other.Bind(wx.EVT_BUTTON, self.OnOtherRemove) btn_catclr.Bind(wx.EVT_BUTTON, self.OnClearCategories) wx.EVT_CHECKBOX(self, inputid.OTHER, self.OnOtherSelect) wx.EVT_CHECKBOX(self, listid.CAT, self.OnCatSelect) # *** Layout *** # LEFT_CENTER = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL LEFT_BOTTOM = wx.ALIGN_LEFT | wx.ALIGN_BOTTOM RIGHT_BOTTOM = wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM 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, wx.LEFT | wx.TOP, 5) lyt_opts1.Add(chk_notify, 0, LEFT_CENTER | wx.LEFT | wx.TOP, 5) lyt_top = BoxSizer(wx.HORIZONTAL) lyt_top.Add(lyt_opts1, 0, wx.EXPAND | wx.ALIGN_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_mid = wx.GridBagSizer() lyt_mid.SetCols(4) lyt_mid.AddGrowableCol(1) lyt_mid.AddGrowableCol(3) # Row 1 row = 0 lyt_mid.Add(txt_name, (row, 0), flag=LEFT_CENTER) lyt_mid.Add(ti_name, (row, 1), flag=wx.EXPAND | wx.LEFT, border=5) lyt_mid.Add(txt_exec, (row, 2), flag=LEFT_CENTER | wx.LEFT, border=5) lyt_mid.Add(ti_exec, (row, 3), flag=wx.EXPAND | wx.LEFT, border=5) # Row 2 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 | wx.LEFT | wx.TOP, border=5) lyt_mid.Add(txt_icon, (row, 2), flag=LEFT_CENTER | wx.LEFT | wx.TOP, border=5) lyt_mid.Add(ti_icon, (row, 3), flag=wx.EXPAND | wx.LEFT | wx.TOP, border=5) # Row 3 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 | wx.LEFT | wx.TOP, border=5) lyt_bottom = wx.GridBagSizer() row = 0 lyt_bottom.Add(txt_other, (row, 0), flag=LEFT_BOTTOM) lyt_bottom.Add(btn_other, (row, 1), flag=RIGHT_BOTTOM) lyt_bottom.Add(btn_rm_other, (row, 2), flag=RIGHT_BOTTOM) lyt_bottom.Add(txt_category, (row, 3), flag=LEFT_BOTTOM | wx.LEFT, border=5) lyt_bottom.Add(btn_catclr, (row, 4), flag=RIGHT_BOTTOM) row += 1 lyt_bottom.Add(pnl_other, (row, 0), (3, 3), wx.EXPAND) lyt_bottom.Add(lst_categories, (row, 3), (1, 2), wx.EXPAND | wx.LEFT, 5) row += 1 lyt_bottom.Add(txt_catcustom, (row, 3), flag=LEFT_BOTTOM | wx.LEFT | wx.TOP, border=5) lyt_bottom.Add(chk_catcustom, (row, 4), flag=RIGHT_BOTTOM) row += 1 lyt_bottom.Add(ti_catcustom, (row, 3), (1, 2), flag=wx.EXPAND | wx.LEFT, border=5) lyt_bottom.AddGrowableRow(1) lyt_bottom.AddGrowableCol(1) lyt_bottom.AddGrowableCol(3) # --- Page 5 Sizer --- # lyt_main = BoxSizer(wx.VERTICAL) lyt_main.AddSpacer(5) lyt_main.Add(lyt_top, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 5) lyt_main.Add(lyt_mid, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5) lyt_main.Add(lyt_bottom, 1, wx.EXPAND | wx.ALL, 5) self.SetAutoLayout(True) self.SetSizer(lyt_main) self.Layout()