def __init__(self, button, label, parent=None, btnId=wx.ID_ANY, size=32, tooltip=None, name=None, showLabel=True): BoxSizer.__init__(self, wx.VERTICAL) if IsString(button): self.Button = CreateButton(parent, btnId, label, button, size, tooltip, name) else: self.Button = button self.Add(self.Button, 1, wx.ALIGN_CENTER) if isinstance(self.Button, CustomButton): if not label: label = self.Button.Name self.Label = wx.StaticText(self.Button.GetParent(), label=label) self.Add(self.Label, 0, wx.ALIGN_CENTER) self.Show(self.Label, showLabel)
def __init__(self, parent, panelClass, winId=wx.ID_ANY): BoxSizer.__init__(self, wx.VERTICAL) self.Panel = panelClass self.Tabs = Notebook(parent, winId) self.TabButtonIds = [] # *** Event Handling *** # self.Tabs.Bind(EVT_AUINOTEBOOK_PAGE_CLOSED, self.OnTabClosed) # *** Layout *** # lyt_buttons = BoxSizer(wx.HORIZONTAL) self.Add(lyt_buttons, 0, wx.EXPAND) self.Add(self.Tabs, 1, wx.EXPAND) # *** Post-Layout Actions *** # self.AddButton(GT(u'Add Tab'), u'add', btnid.ADD, self.OnButtonAdd) self.AddTabButton(GT(u'Rename Tab'), u'rename', btnid.RENAME, self.OnRenameTab)
def __init__(self, orient): BoxSizer.__init__(self, orient)
def __init__(self, parent, size=(600, 558)): wx.Dialog.__init__(self, parent, wx.ID_ABOUT, GT(u'About'), size=size, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.SetMinSize(wx.Size(400, 375)) self.CenterOnParent() # Create a tabbed interface tabs = wx.Notebook(self, -1) # Pages self.t_about = wx.Panel(tabs, -1) t_credits = wx.Panel(tabs, -1) t_changelog = wx.Panel(tabs, -1) t_license = wx.Panel(tabs, -1) # Add pages to tabbed interface tabs.AddPage(self.t_about, GT(u'About')) tabs.AddPage(t_credits, GT(u'Credits')) tabs.AddPage(t_changelog, GT(u'Changelog')) tabs.AddPage(t_license, GT(u'License')) # FIXME: Center verticall on about tab self.about_layout_V1 = BoxSizer(wx.VERTICAL) self.about_layout_V1.AddStretchSpacer() self.about_layout_V1.AddStretchSpacer() self.t_about.SetAutoLayout(True) self.t_about.SetSizer(self.about_layout_V1) self.t_about.Layout() ## List of credits self.credits = ListCtrl(t_credits) self.credits.SetSingleStyle(wx.LC_REPORT) self.credits.InsertColumn(0, GT(u'Name'), width=150) self.credits.InsertColumn(1, GT(u'Job'), width=200) self.credits.InsertColumn(2, GT(u'Email'), width=240) credits_sizer = BoxSizer(wx.VERTICAL) credits_sizer.Add(self.credits, 1, wx.EXPAND) t_credits.SetAutoLayout(True) t_credits.SetSizer(credits_sizer) t_credits.Layout() ## Changelog text area self.changelog = TextAreaPanel(t_changelog, style=wx.TE_READONLY) self.changelog.SetFont(MONOSPACED_MD) log_sizer = BoxSizer(wx.VERTICAL) log_sizer.Add(self.changelog, 1, wx.EXPAND) t_changelog.SetSizer(log_sizer) t_changelog.Layout() ## Licensing information text area self.license = TextAreaPanel(t_license, style=wx.TE_READONLY) self.license.SetFont(MONOSPACED_MD) license_sizer = BoxSizer(wx.VERTICAL) license_sizer.Add(self.license, 1, wx.EXPAND) t_license.SetSizer(license_sizer) t_license.Layout() # System info sys_info = wx.Panel(tabs, -1) tabs.AddPage(sys_info, GT(u'System Information')) ## System's <a href="https://www.python.org/">Python</a> version self.py_info = wx.StaticText( sys_info, -1, GT(u'Python version: {}').format(PY_VER_STRING)) ## System's <a href="https://wxpython.org/">wxPython</a> version self.wx_info = wx.StaticText( sys_info, -1, GT(u'wxPython version: {}').format(WX_VER_STRING)) ## Debreate's installation prefix install_prefix = wx.StaticText( sys_info, label=GT(u'App location: {}').format(PATH_app)) if INSTALLED: install_prefix.SetLabel( GT(u'Installation prefix: {}').format(PREFIX)) self.py_info.SetFont(sys_info_font) self.wx_info.SetFont(sys_info_font) sysinfo_layout_V1 = BoxSizer(wx.VERTICAL) sysinfo_layout_V1.AddStretchSpacer() sysinfo_layout_V1.Add(self.py_info, 0, wx.ALIGN_CENTER | wx.BOTTOM, 5) sysinfo_layout_V1.Add(self.wx_info, 0, wx.ALIGN_CENTER | wx.TOP, 5) sysinfo_layout_V1.AddSpacer(20) sysinfo_layout_V1.Add(install_prefix, 0, wx.ALIGN_CENTER | wx.TOP, 5) sysinfo_layout_V1.AddStretchSpacer() sys_info.SetSizer(sysinfo_layout_V1) sys_info.Layout() # Button to close the dialog btn_confirm = CreateButton(self, btnid.CONFIRM) sizer = BoxSizer(wx.VERTICAL) sizer.Add(tabs, 1, wx.EXPAND) sizer.Add(btn_confirm, 0, wx.ALIGN_RIGHT | lyt.PAD_RTB, 5) self.SetSizer(sizer) self.Layout()
def __init__(self, parent): WizardPage.__init__(self, parent, pgid.DEPENDS) ## Override default label self.SetLabel(GT(u'Dependencies and Conflicts')) # Bypass checking this page for build self.prebuild_check = False # Buttons to open, save, & preview control file self.btn_open = CreateButton(self, btnid.BROWSE, GT(u'Browse'), u'browse', name=u'btn browse') self.btn_save = CreateButton(self, btnid.SAVE, GT(u'Save'), u'save', name=u'btn save') self.btn_preview = CreateButton(self, btnid.PREVIEW, GT(u'Preview'), u'preview', name=u'btn preview') txt_package = wx.StaticText( self, label=GT(u'Dependency/Conflict Package Name'), name=u'package') txt_version = wx.StaticText(self, label=GT(u'Version'), name=u'version') self.ti_package = TextArea(self, size=(300, 25), name=u'package') opts_operator = ( u'>=', u'<=', u'=', u'>>', u'<<', ) self.sel_operator = Choice(self, choices=opts_operator, name=u'operator') self.ti_version = TextArea(self, name=u'version') self.ti_package.SetSize((100, 50)) pnl_categories = BorderedPanel(self) self.DefaultCategory = u'Depends' rb_dep = wx.RadioButton(pnl_categories, label=GT(u'Depends'), name=self.DefaultCategory, style=wx.RB_GROUP) rb_pre = wx.RadioButton(pnl_categories, label=GT(u'Pre-Depends'), name=u'Pre-Depends') rb_rec = wx.RadioButton(pnl_categories, label=GT(u'Recommends'), name=u'Recommends') rb_sug = wx.RadioButton(pnl_categories, label=GT(u'Suggests'), name=u'Suggests') rb_enh = wx.RadioButton(pnl_categories, label=GT(u'Enhances'), name=u'Enhances') rb_con = wx.RadioButton(pnl_categories, label=GT(u'Conflicts'), name=u'Conflicts') rb_rep = wx.RadioButton(pnl_categories, label=GT(u'Replaces'), name=u'Replaces') rb_break = wx.RadioButton(pnl_categories, label=GT(u'Breaks'), name=u'Breaks') self.categories = ( rb_dep, rb_pre, rb_rec, rb_sug, rb_enh, rb_con, rb_rep, rb_break, ) # Buttons to add and remove dependencies from the list btn_add = CreateButton(self, btnid.ADD) btn_append = CreateButton(self, btnid.APPEND) btn_remove = CreateButton(self, btnid.REMOVE) btn_clear = CreateButton(self, btnid.CLEAR) # ----- List self.lst_deps = ListCtrlESS(self, inputid.LIST, name=u'list') self.lst_deps.SetSingleStyle(wx.LC_REPORT) self.lst_deps.InsertColumn(0, GT(u'Category'), width=150) self.lst_deps.InsertColumn(1, GT(u'Package(s)')) # wx 3.0 compatibility if wx.MAJOR_VERSION < 3: self.lst_deps.SetColumnWidth(100, wx.LIST_AUTOSIZE) SetPageToolTips(self) # *** Event Handling *** # wx.EVT_KEY_DOWN(self.ti_package, self.SetDepends) wx.EVT_KEY_DOWN(self.ti_version, self.SetDepends) btn_add.Bind(wx.EVT_BUTTON, self.SetDepends) btn_append.Bind(wx.EVT_BUTTON, self.SetDepends) btn_remove.Bind(wx.EVT_BUTTON, self.SetDepends) btn_clear.Bind(wx.EVT_BUTTON, self.SetDepends) wx.EVT_KEY_DOWN(self.lst_deps, self.SetDepends) # *** Layout *** # LEFT_BOTTOM = lyt.ALGN_LB lyt_top = wx.GridBagSizer() lyt_top.SetCols(6) lyt_top.AddGrowableCol(3) # Row 1 lyt_top.Add(txt_package, (1, 0), flag=LEFT_BOTTOM) lyt_top.Add(txt_version, (1, 2), flag=LEFT_BOTTOM) lyt_top.Add(self.btn_open, (0, 3), (4, 1), wx.ALIGN_RIGHT) lyt_top.Add(self.btn_save, (0, 4), (4, 1)) lyt_top.Add(self.btn_preview, (0, 5), (4, 1)) # Row 2 lyt_top.Add(self.ti_package, (2, 0), flag=wx.ALIGN_CENTER_VERTICAL) lyt_top.Add(self.sel_operator, (2, 1), flag=wx.ALIGN_CENTER_VERTICAL) lyt_top.Add(self.ti_version, (2, 2), flag=wx.ALIGN_CENTER_VERTICAL) lyt_categories = wx.GridSizer(4, 2, 5, 5) for C in self.categories: lyt_categories.Add(C, 0) pnl_categories.SetAutoLayout(True) pnl_categories.SetSizer(lyt_categories) pnl_categories.Layout() lyt_buttons = BoxSizer(wx.HORIZONTAL) lyt_buttons.AddMany(( (btn_add, 0, wx.ALIGN_CENTER_VERTICAL), (btn_append, 0, wx.ALIGN_CENTER_VERTICAL), (btn_remove, 0, wx.ALIGN_CENTER_VERTICAL), (btn_clear, 0, wx.ALIGN_CENTER_VERTICAL), )) lyt_mid = wx.GridBagSizer() lyt_mid.SetCols(2) lyt_mid.Add(wx.StaticText(self, label=u'Categories'), (0, 0), (1, 1), LEFT_BOTTOM) lyt_mid.Add(pnl_categories, (1, 0), flag=wx.RIGHT, border=5) lyt_mid.Add(lyt_buttons, (1, 1), flag=wx.ALIGN_BOTTOM) lyt_list = BoxSizer(wx.HORIZONTAL) lyt_list.Add(self.lst_deps, 1, wx.EXPAND) lyt_main = BoxSizer(wx.VERTICAL) # Spacer is less on this page because text is aligned to bottom lyt_main.AddSpacer(5) lyt_main.Add(lyt_top, 0, wx.EXPAND | lyt.PAD_LR, 5) lyt_main.Add(lyt_mid, 0, lyt.PAD_LR, 5) lyt_main.Add(lyt_list, 1, wx.EXPAND | wx.ALL, 5) self.SetAutoLayout(True) self.SetSizer(lyt_main) self.Layout()
class AboutDialog(wx.Dialog): ## Constructor # # \param parent # The parent window # \param id # Window id (FIXME: Not necessary) # \param title # Text to be shown in the title bar def __init__(self, parent, size=(600, 558)): wx.Dialog.__init__(self, parent, wx.ID_ABOUT, GT(u'About'), size=size, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.SetMinSize(wx.Size(400, 375)) self.CenterOnParent() # Create a tabbed interface tabs = wx.Notebook(self, -1) # Pages self.t_about = wx.Panel(tabs, -1) t_credits = wx.Panel(tabs, -1) t_changelog = wx.Panel(tabs, -1) t_license = wx.Panel(tabs, -1) # Add pages to tabbed interface tabs.AddPage(self.t_about, GT(u'About')) tabs.AddPage(t_credits, GT(u'Credits')) tabs.AddPage(t_changelog, GT(u'Changelog')) tabs.AddPage(t_license, GT(u'License')) # FIXME: Center verticall on about tab self.about_layout_V1 = BoxSizer(wx.VERTICAL) self.about_layout_V1.AddStretchSpacer() self.about_layout_V1.AddStretchSpacer() self.t_about.SetAutoLayout(True) self.t_about.SetSizer(self.about_layout_V1) self.t_about.Layout() ## List of credits self.credits = ListCtrl(t_credits) self.credits.SetSingleStyle(wx.LC_REPORT) self.credits.InsertColumn(0, GT(u'Name'), width=150) self.credits.InsertColumn(1, GT(u'Job'), width=200) self.credits.InsertColumn(2, GT(u'Email'), width=240) credits_sizer = BoxSizer(wx.VERTICAL) credits_sizer.Add(self.credits, 1, wx.EXPAND) t_credits.SetAutoLayout(True) t_credits.SetSizer(credits_sizer) t_credits.Layout() ## Changelog text area self.changelog = TextAreaPanel(t_changelog, style=wx.TE_READONLY) self.changelog.SetFont(MONOSPACED_MD) log_sizer = BoxSizer(wx.VERTICAL) log_sizer.Add(self.changelog, 1, wx.EXPAND) t_changelog.SetSizer(log_sizer) t_changelog.Layout() ## Licensing information text area self.license = TextAreaPanel(t_license, style=wx.TE_READONLY) self.license.SetFont(MONOSPACED_MD) license_sizer = BoxSizer(wx.VERTICAL) license_sizer.Add(self.license, 1, wx.EXPAND) t_license.SetSizer(license_sizer) t_license.Layout() # System info sys_info = wx.Panel(tabs, -1) tabs.AddPage(sys_info, GT(u'System Information')) ## System's <a href="https://www.python.org/">Python</a> version self.py_info = wx.StaticText( sys_info, -1, GT(u'Python version: {}').format(PY_VER_STRING)) ## System's <a href="https://wxpython.org/">wxPython</a> version self.wx_info = wx.StaticText( sys_info, -1, GT(u'wxPython version: {}').format(WX_VER_STRING)) ## Debreate's installation prefix install_prefix = wx.StaticText( sys_info, label=GT(u'App location: {}').format(PATH_app)) if INSTALLED: install_prefix.SetLabel( GT(u'Installation prefix: {}').format(PREFIX)) self.py_info.SetFont(sys_info_font) self.wx_info.SetFont(sys_info_font) sysinfo_layout_V1 = BoxSizer(wx.VERTICAL) sysinfo_layout_V1.AddStretchSpacer() sysinfo_layout_V1.Add(self.py_info, 0, wx.ALIGN_CENTER | wx.BOTTOM, 5) sysinfo_layout_V1.Add(self.wx_info, 0, wx.ALIGN_CENTER | wx.TOP, 5) sysinfo_layout_V1.AddSpacer(20) sysinfo_layout_V1.Add(install_prefix, 0, wx.ALIGN_CENTER | wx.TOP, 5) sysinfo_layout_V1.AddStretchSpacer() sys_info.SetSizer(sysinfo_layout_V1) sys_info.Layout() # Button to close the dialog btn_confirm = CreateButton(self, btnid.CONFIRM) sizer = BoxSizer(wx.VERTICAL) sizer.Add(tabs, 1, wx.EXPAND) sizer.Add(btn_confirm, 0, wx.ALIGN_RIGHT | lyt.PAD_RTB, 5) self.SetSizer(sizer) self.Layout() ## Displays logo in 'about' tab # # \param graphic # Path to image file def SetGraphic(self, graphic): insertion_point = GetContainerItemCount(self.about_layout_V1) - 1 if not isinstance(graphic, wx.Bitmap): graphic = wx.Image(graphic) graphic.Rescale(64, 64, wx.IMAGE_QUALITY_HIGH) graphic = graphic.ConvertToBitmap() self.about_layout_V1.Insert( insertion_point, wx.StaticBitmap(self.t_about, wx.ID_ANY, graphic), 0, wx.ALL | wx.ALIGN_CENTER, 10) self.t_about.Layout() ## Displays version in 'about' tab # # \param version # String to display def SetVersion(self, version): insertion_point = GetContainerItemCount(self.about_layout_V1) - 1 app_label = wx.StaticText(self.t_about, label=u'{} {}'.format(APP_name, version)) app_label.SetFont(bigfont) self.about_layout_V1.Insert(insertion_point, app_label, 0, wx.ALL | wx.ALIGN_CENTER, 10) self.t_about.Layout() ## Display author's name # # \param author # String to display def SetAuthor(self, author): insertion_point = GetContainerItemCount(self.about_layout_V1) - 1 self.about_layout_V1.Insert(insertion_point, wx.StaticText(self.t_about, label=author), 0, wx.ALL | wx.ALIGN_CENTER, 10) self.t_about.Layout() ## Sets a hotlink to the app's homepage # # TODO: Remove: Deprecated, unused # \param URL # URL to open when link is clicked def SetWebsite(self, URL): self.website.SetLabel(URL) self.website.SetURL(URL) ## Adds URL hotlinks to about dialog # # \param url_list # \b \e tuple : Website labels & URL definitions def SetWebsites(self, url_list): insertion_point = GetContainerItemCount(self.about_layout_V1) - 1 link_layout = BoxSizer(wx.VERTICAL) for label, link in url_list: link_layout.Add( Hyperlink(self.t_about, wx.ID_ANY, label=label, url=link), 0, wx.ALIGN_CENTER, 10) self.about_layout_V1.Insert(insertion_point, link_layout, 0, wx.ALL | wx.ALIGN_CENTER, 10) self.t_about.Layout() ## Displays a description about the app on the 'about' tab def SetDescription(self, desc): # Place between spacers insertion_point = GetContainerItemCount(self.about_layout_V1) - 1 self.about_layout_V1.Insert(insertion_point, wx.StaticText(self.t_about, label=desc), 0, wx.ALL | wx.ALIGN_CENTER, 10) self.t_about.Layout() ## Adds a developer to the list of credits # # \param name # str: Developer's name # \param email # str: Developer's email address def AddDeveloper(self, name, email): next_item = self.credits.GetItemCount() self.credits.InsertStringItem(next_item, name) self.credits.SetStringItem(next_item, 2, email) self.credits.SetStringItem(next_item, 1, GT(u'Developer')) ## Adds a packager to the list of credits # # \param name # \b \e str : Packager's name # \param email # \b \e str : Packager's email address def AddPackager(self, name, email): next_item = self.credits.GetItemCount() self.credits.InsertStringItem(next_item, name) self.credits.SetStringItem(next_item, 2, email) self.credits.SetStringItem(next_item, 1, GT(u'Packager')) ## Adds a translator to the list of credits # # \param name # \b \e str : Translator's name # \param email # \b \e str : Translator's email address # \param lang # \b \e str : Locale code for the translation def AddTranslator(self, name, email, lang): job = GT(u'Translation') job = u'{} ({})'.format(job, lang) next_item = self.credits.GetItemCount() self.credits.InsertStringItem(next_item, name) self.credits.SetStringItem(next_item, 2, email) self.credits.SetStringItem(next_item, 1, job) ## Adds a general job to the credits list # # \param name # \b \e str : Contributer's name # \param job # \b \e str : Job description # \param email # \b \e str : Job holder's email address def AddJob(self, name, job, email=wx.EmptyString): next_item = self.credits.GetItemCount() self.credits.InsertStringItem(next_item, name) self.credits.SetStringItem(next_item, 1, job) if email != wx.EmptyString: self.credits.SetStringItem(next_item, 2, email) ## Adds list of jobs for single contributer # # \param name # \b \e unicode|str : Contributer's name # \param jobs # \b \e string \b \e list|tuple : Contributer's jobs # \param email # \b \e unicode|str : Optional contributer's email address def AddJobs(self, name, jobs, email=wx.EmptyString): if isinstance(jobs, str) or isinstance(jobs, unicode): Logger.Debug(__name__, GT(u'Converting string argument "jobs" to tuple')) jobs = (jobs, ) for x, value in enumerate(jobs): next_item = self.credits.GetItemCount() if x == 0: self.credits.InsertStringItem(next_item, name) if email != wx.EmptyString: self.credits.SetStringItem(next_item, 2, email) else: self.credits.InsertStringItem(next_item, wx.EmptyString) self.credits.SetStringItem(next_item, 1, value) # FIXME: Unused? def NoResizeCol(self, event=None): if event: event.Veto() ## Sets text to be shown on the 'Changelog' tab # # FIXME: Change to create in class constructor # \param log_file # \b \e str : Path to changelog file on filesystem def SetChangelog(self): ## Defines where the changelog is located # # By default it is located in the folder 'doc' # under the applications root directory. The # install script or Makefile should change this # to reflect installed path. CHANGELOG = u'{}/docs/changelog'.format(PATH_app) if os.path.isfile(CHANGELOG): changelog_mimetype = GetFileMimeType(CHANGELOG) Logger.Debug( __name__, GT(u'Changelog mimetype: {}').format(changelog_mimetype)) # Set log text in case of read error log_text = GT(u'Error reading changelog: {}\n\t').format(CHANGELOG) log_text = u'{}{}'.format( log_text, GT(u'Cannot decode, unrecognized mimetype: {}').format( changelog_mimetype)) if changelog_mimetype == u'text/plain': log_text = ReadFile(CHANGELOG) else: ShowErrorDialog(log_text, parent=self) else: log_text = GT( u'ERROR: Could not locate changelog file:\n\t\'{}\' not found'. format(CHANGELOG)) self.changelog.SetValue(log_text) self.changelog.SetInsertionPoint(0) ## Sets text to be shown on the 'License' tab # # \param lic_file # \b \e : Path to license file on the filesystem def SetLicense(self): ## Defines where the LICENSE.txt is located # # By default it is located in the folder 'doc' # under the applications root directory. The # install script or Makefile should change this # to reflect installed path. license_path = u'{}/docs/LICENSE.txt'.format(PATH_app) if os.path.isfile(license_path): lic_text = ReadFile(license_path) else: lic_text = GT( u'ERROR: Could not locate license file:\n\t\'{}\' not found'. format(license_path)) lic_text += u'\n\nCopyright © {} {} <{}>'.format( GetYear(), AUTHOR_name, AUTHOR_email) lic_text += u'\n\nhttps://opensource.org/licenses/MIT' self.license.SetValue(lic_text) self.license.SetInsertionPoint(0) ## Defines action to take when 'Ok' button is press # # Closes the dialog. # \param event # <b><em>(wx.EVT_BUTTON)</em></b> def OnOk(self, event=None): self.Close()
def __init__(self, parent): WizardPage.__init__(self, parent, pgid.CONTROL) 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()
class DetailedMessageDialog(BaseDialog, ButtonDialog): def __init__(self, parent, title=GT(u'Message'), icon=ICON_INFORMATION, text=wx.EmptyString, details=wx.EmptyString, style=wx.DEFAULT_DIALOG_STYLE, buttons=(wx.ID_OK, ), linewrap=0): BaseDialog.__init__(self, parent, wx.ID_ANY, title, style=style) # Allow using strings for 'icon' argument if isinstance(icon, (unicode, str)): icon = wx.Bitmap(icon) icon = wx.StaticBitmap(self, wx.ID_ANY, icon) txt_message = wx.StaticText(self, label=text) if linewrap: txt_message.Wrap(linewrap) # self.details needs to be empty for constructor self.details = wx.EmptyString details = details # *** Layout *** # self.lyt_urls = BoxSizer(wx.VERTICAL) # Only set if buttons are added to dialog self.lyt_buttons = None lyt_main = wx.GridBagSizer(5, 5) lyt_main.SetCols(3) lyt_main.AddGrowableRow(3) lyt_main.AddGrowableCol(2) lyt_main.Add(icon, (0, 0), (5, 1), wx.ALIGN_TOP | lyt.PAD_LR | wx.BOTTOM, 20) lyt_main.Add(txt_message, (0, 1), (1, 2), lyt.PAD_RT, 20) lyt_main.Add(self.lyt_urls, (1, 1), (1, 2), wx.RIGHT, 5) self.SetAutoLayout(True) self.SetSizer(lyt_main) self.AddButtons(buttons) if not TextIsEmpty(details): # self.details will be set here self.CreateDetailedView(details) else: self.Layout() self.Fit() self.SetMinSize(self.GetSize()) self.CenterOnParent() ## Add custom buttons to dialog # # NOTE: Do not call before self.SetSizer # # FIXME: Rename to SetButtons??? # FIXME: Should delete any previous buttons def AddButtons(self, button_ids): self.lyt_buttons = AddCustomButtons(self, button_ids) self.Sizer.Add(self.lyt_buttons, (4, 2), flag=wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM | lyt.PAD_RTB, border=5) ## Adds a clickable link to the dialog def AddURL(self, url): if not isinstance(url, Hyperlink): url = Hyperlink(self, wx.ID_ANY, label=url, url=url) self.lyt_urls.Add(url, 0, wx.ALIGN_CENTER_VERTICAL) self.Layout() self.Fit() self.SetMinSize(self.GetSize()) self.CenterOnParent() ## Shows dialog modal & returns 'confirmed' value # # \return # \b \e bool : True if ShowModal return value one of wx.ID_OK, wx.OK, wx.ID_YES, wx.YES def Confirmed(self): return self.ShowModal() in (wx.ID_OK, wx.OK, wx.ID_YES, wx.YES) ## Adds buttons & details text to dialog # # \param details # \b \e unicode|str : Detailed text to show in dialog def CreateDetailedView(self, details): # Controls have not been constructed yet if TextIsEmpty(self.details): self.btn_details = wx.ToggleButton(self, label=GT(u'Details')) #btn_copy = wx.Button(self, label=GT(u'Copy details')) self.dsp_details = TextAreaPanel(self, value=details, style=wx.TE_READONLY) # *** Event handlers *** # self.btn_details.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleDetails) #btn_copy.Bind(wx.EVT_BUTTON, self.OnCopyDetails) layout = self.GetSizer() layout.Add(self.btn_details, (2, 1)) #layout.Add(btn_copy, (2, 2), flag=wx.ALIGN_LEFT|wx.RIGHT, border=5) layout.Add(self.dsp_details, (3, 1), (1, 2), wx.EXPAND | wx.RIGHT, 5) self.ToggleDetails() if not TextIsEmpty(details): for C in self.GetChildren(): if isinstance(C, TextAreaPanel): self.details = details C.SetValue(self.details) return True return False ## Attempts to retrieve button instance matching btn_id # # FIXME: This will fail if there are standard buttons in the dialog # FIXME: Retrieving by label doesn't work # \param btn_id # ID of the button instance to retrieve # \return # \b \e wx.Button instance or None def GetButton(self, btn_id): # Allow search by label use_label = not isinstance(btn_id, int) if self.lyt_buttons: for sizer in self.lyt_buttons.GetChildren(): sizer = sizer.GetSizer() btn_layout = sizer.GetChildren() if btn_layout: BTN = btn_layout[0].GetWindow() LBL = None if len(btn_layout) < 2 and isinstance(BTN, wx.Button): LBL = BTN.GetLabel() else: LBL = btn_layout[1] if isinstance(LBL, wx.StaticText): LBL = LBL.GetLabel() if not use_label: if BTN.GetId() == btn_id: return BTN else: if LBL == btn_id: return BTN ## TODO: Doxygen # # FIXME: Layout initially wrong # TODO: Allow copying details to clipboard def OnCopyDetails(self, event=None): print(u'DEBUG: Copying details to clipboard ...') DetailedMessageDialog( self, u'FIXME', ICON_EXCLAMATION, u'Copying details to clipboard not functional').ShowModal() return cb_set = False clipboard = wx.Clipboard() if clipboard.Open(): print(u'DEBUG: Clipboard opened') details = wx.TextDataObject(self.dsp_details.GetValue()) print(u'DEBUG: Details set to:\n{}'.format(details.GetText())) clipboard.Clear() print(u'DEBUG: Clipboard cleared') cb_set = clipboard.SetData(details) print(u'DEBUG: Clipboard data set') clipboard.Flush() print(u'DEBUG: Clipboard flushed') clipboard.Close() print(u'DEBUG: Clipboard cloased') del clipboard print(u'DEBUG: Clipboard object deleted') wx.MessageBox(u'FIXME: Details not copied to clipboard', GT(u'Debug')) ## Override inherited method to center on parent window first def ShowModal(self, *args, **kwargs): if self.Parent: self.CenterOnParent() return wx.Dialog.ShowModal(self, *args, **kwargs) ## TODO: Doxygen def SetDetails(self, details): return self.CreateDetailedView(details) ## TODO: Doxygen def ToggleDetails(self, event=None): try: if self.btn_details.GetValue(): self.dsp_details.Show() else: self.dsp_details.Hide() self.Layout() self.Fit() self.SetMinSize(self.GetSize()) return True except AttributeError: # Disable toggling details self.btn_details.Hide() self.Layout() self.Fit() self.SetMinSize(self.GetSize()) return False
def __init__(self): BaseDialog.__init__(self, title=GT(u'Update Dist Names Cache'), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) ModuleAccessCtrl.__init__(self, __name__) self.SetMinSize(wx.Size(300, 150)) txt_types = wx.StaticText(self, label=GT(u'Include the following:')) pnl_types = BorderedPanel(self) self.chk_unstable = wx.CheckBox(pnl_types, label=GT(u'Unstable')) self.chk_obsolete = wx.CheckBox(pnl_types, label=GT(u'Obsolete')) self.chk_generic = wx.CheckBox( pnl_types, label=GT(u'Generic (Debian names only)')) self.btn_preview = wx.Button(self, label=GT(u'Preview cache')) btn_update = wx.Button(self, label=GT(u'Update cache')) btn_clear = wx.Button(self, label=GT(u'Clear cache')) # Keep preview dialog in memory so position/size is saved self.preview = TextPreview(self, title=GT(u'Available Distribution Names'), size=(500, 400)) # Is instantiated as ProgressDialog when OnUpdateCache is called self.progress = None self.timer = DebreateTimer(self) # For setting error messages from other threads self.error_message = None # *** Event Handling *** # self.btn_preview.Bind(wx.EVT_BUTTON, self.OnPreviewCache) btn_update.Bind(wx.EVT_BUTTON, self.OnUpdateCache) btn_clear.Bind(wx.EVT_BUTTON, self.OnClearCache) self.Bind(wx.EVT_TIMER, self.OnTimerEvent) self.Bind(EVT_TIMER_STOP, self.OnTimerStop) # *** Layout *** # lyt_types = BoxSizer(wx.VERTICAL) lyt_types.AddSpacer(5) for CHK in ( self.chk_unstable, self.chk_obsolete, self.chk_generic, ): lyt_types.Add(CHK, 0, lyt.PAD_LR, 5) lyt_types.AddSpacer(5) pnl_types.SetAutoLayout(True) pnl_types.SetSizerAndFit(lyt_types) pnl_types.Layout() lyt_buttons = BoxSizer(wx.HORIZONTAL) lyt_buttons.Add(self.btn_preview, 1) lyt_buttons.Add(btn_update, 1) lyt_buttons.Add(btn_clear, 1) lyt_main = BoxSizer(wx.VERTICAL) lyt_main.Add(txt_types, 0, wx.ALIGN_CENTER | lyt.PAD_LRT, 5) lyt_main.Add(pnl_types, 0, wx.ALIGN_CENTER | lyt.PAD_LR, 5) lyt_main.Add(lyt_buttons, 1, wx.ALIGN_CENTER | wx.ALL, 5) self.SetAutoLayout(True) self.SetSizer(lyt_main) self.Layout() # *** Post-layout Actions *** # if not os.path.isfile(FILE_distnames): self.btn_preview.Disable() if self.Parent: self.CenterOnParent()
def __init__(self, parent, pageList=None): wx.Panel.__init__(self, parent, wx.ID_ANY, pageList) testing = u'alpha' in GetTestList() # List of pages available in the wizard self.Pages = [] self.PagesIds = {} # IDs for first & last pages self.ID_FIRST = None self.ID_LAST = None if testing: # Help button btn_help = CreateButton(self, btnid.HELP) btn_help.SetToolTipString(GT(u'Page help')) # A Header for the wizard pnl_title = wx.Panel(self, style=wx.RAISED_BORDER) pnl_title.SetBackgroundColour((10, 47, 162)) # Text displayed from objects "name" - object.GetName() self.txt_title = wx.StaticText(pnl_title, label=GT(u'Title')) self.txt_title.SetForegroundColour((255, 255, 255)) # font to use in the header headerfont = wx.Font(18, wx.DEFAULT, wx.NORMAL, wx.BOLD) self.txt_title.SetFont(headerfont) # Previous and Next buttons self.btn_prev = CreateButton(self, btnid.PREV) self.btn_prev.SetToolTip(TT_wiz_prev) self.btn_next = CreateButton(self, btnid.NEXT) self.btn_next.SetToolTip(TT_wiz_next) # These widgets are put into a list so that they are not automatically hidden self.permanent_children = [ pnl_title, self.btn_prev, self.btn_next, ] if testing: self.permanent_children.insert(0, btn_help) # *** Event Handling *** # if testing: btn_help.Bind(wx.EVT_BUTTON, self.OnHelpButton) self.btn_prev.Bind(wx.EVT_BUTTON, self.ChangePage) self.btn_next.Bind(wx.EVT_BUTTON, self.ChangePage) # *** Layout *** # # Position the text in the header lyt_title = wx.GridSizer(1, 1) lyt_title.Add(self.txt_title, 0, wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL) pnl_title.SetSizer(lyt_title) # Button sizer includes header lyt_buttons = BoxSizer(wx.HORIZONTAL) if testing: lyt_buttons.Add(btn_help, 0, wx.LEFT, 5) lyt_buttons.AddSpacer(5) lyt_buttons.Add(pnl_title, 1, wx.EXPAND | wx.RIGHT, 5) lyt_buttons.Add(self.btn_prev) lyt_buttons.AddSpacer(5) lyt_buttons.Add(self.btn_next) lyt_buttons.AddSpacer(5) lyt_main = BoxSizer(wx.VERTICAL) lyt_main.Add(lyt_buttons, 0, wx.EXPAND) self.SetSizer(lyt_main) self.SetAutoLayout(True) self.Layout()
def __init__(self, parent): wx.Dialog.__init__(self, parent, title=GT(u'Quick Build'), pos=wx.DefaultPosition, size=wx.Size(400, 260)) self.title = self.GetTitle() label_stage = wx.StaticText(self, label=GT(u'Staged directory tree')) self.input_stage = wx.TextCtrl(self) self.input_stage.SetToolTip( wx.ToolTip(GT(u'Root directory of build tree'))) btn_browse_stage = CreateButton(self, btnid.STAGE, image=u'browse') btn_browse_stage.Bind(wx.EVT_BUTTON, self.OnBrowse) label_target = wx.StaticText(self, label=GT(u'Target file')) self.input_target = wx.TextCtrl(self) self.input_target.SetToolTip(wx.ToolTip(GT(u'Target output file'))) btn_browse_target = CreateButton(self, btnid.TARGET, image=u'browse') btn_browse_target.Bind(wx.EVT_BUTTON, self.OnBrowse) btn_build = CreateButton(self, btnid.BUILD) btn_build.SetToolTip(wx.ToolTip(GT(u'Start building'))) btn_build.Bind(wx.EVT_BUTTON, self.OnBuild) btn_cancel = CreateButton(self, btnid.EXIT) btn_cancel.SetToolTip(wx.ToolTip(GT(u'Close dialog'))) btn_cancel.Bind(wx.EVT_BUTTON, self.OnClose) self.gauge = wx.Gauge(self, GAUGE_MAX) self.timer = DebreateTimer(self) self.Bind(wx.EVT_TIMER, self.OnUpdateProgress) self.Bind(EVT_TIMER_STOP, self.OnTimerStop) # *** Layout *** # Lstage_V1 = BoxSizer(wx.VERTICAL) Lstage_V1.Add(label_stage, 0, wx.ALIGN_LEFT) Lstage_V1.Add(self.input_stage, 1, wx.EXPAND) Lstage_H1 = BoxSizer(wx.HORIZONTAL) Lstage_H1.Add(Lstage_V1, 3, wx.ALIGN_TOP) Lstage_H1.Add(btn_browse_stage, 0, wx.ALIGN_TOP | wx.TOP, 7) Ltarget_V1 = BoxSizer(wx.VERTICAL) Ltarget_V1.Add(label_target, 0, wx.ALIGN_LEFT) Ltarget_V1.Add(self.input_target, 1, wx.EXPAND) Ltarget_H1 = BoxSizer(wx.HORIZONTAL) Ltarget_H1.Add(Ltarget_V1, 3, wx.ALIGN_TOP) Ltarget_H1.Add(btn_browse_target, 0, wx.ALIGN_TOP | wx.TOP, 7) Lbtn_H1 = BoxSizer(wx.HORIZONTAL) Lbtn_H1.Add(btn_build, 1, wx.ALIGN_BOTTOM | wx.RIGHT, 2) Lbtn_H1.Add(btn_cancel, 1, wx.ALIGN_BOTTOM | wx.LEFT, 2) Lguage_H1 = BoxSizer(wx.HORIZONTAL) Lguage_H1.Add(self.gauge, 1, lyt.PAD_LR, 5) Lmain_V = BoxSizer(wx.VERTICAL) Lmain_V.AddSpacer(1, wx.EXPAND) Lmain_V.Add(Lstage_H1, -1, wx.EXPAND | lyt.PAD_LR, 5) Lmain_V.Add(Ltarget_H1, -1, wx.EXPAND | lyt.PAD_LR, 5) Lmain_V.Add(Lbtn_H1, -1, wx.ALIGN_CENTER | wx.ALL, 5) Lmain_V.Add(Lguage_H1, -1, wx.EXPAND | wx.ALL, 5) Lmain_V.AddSpacer(1, wx.EXPAND) self.SetAutoLayout(True) self.SetSizer(Lmain_V) self.Layout() self.Bind(wx.EVT_CLOSE, self.OnClose) self.CenterOnParent() # For showing error dialog after build thread exits self.build_error = None