def __init__(self, parent): WizardPage.__init__(self, parent, pgid.DEPENDS) ## Override default label self.Label = 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()
def __init__(self, parent): WizardPage.__init__(self, parent, pgid.SCRIPTS) preinst = DebianScript(self, ID_INST_PRE) postinst = DebianScript(self, ID_INST_POST) prerm = DebianScript(self, ID_RM_PRE) postrm = DebianScript(self, ID_RM_POST) # Radio buttons for displaying between pre- and post- install scripts # FIXME: Names settings for tooltips are confusing rb_preinst = wx.RadioButton(self, preinst.GetId(), preinst.GetName(), name=preinst.FileName, style=wx.RB_GROUP) rb_postinst = wx.RadioButton(self, postinst.GetId(), postinst.GetName(), name=postinst.FileName) rb_prerm = wx.RadioButton(self, prerm.GetId(), prerm.GetName(), name=prerm.FileName) rb_postrm = wx.RadioButton(self, postrm.GetId(), postrm.GetName(), name=postrm.FileName) self.script_objects = ( (preinst, rb_preinst,), (postinst, rb_postinst,), (prerm, rb_prerm,), (postrm, rb_postrm,), ) # *** Auto-Link *** # pnl_autolink = BorderedPanel(self) # Auto-Link path for new link txt_autolink = wx.StaticText(pnl_autolink, label=GT(u'Path'), name=u'target') self.ti_autolink = PathCtrl(pnl_autolink, value=u'/usr/bin', warn=True) self.ti_autolink.SetName(u'target') self.ti_autolink.Default = self.ti_autolink.GetValue() # Auto-Link executables to be linked self.Executables = BasicFileList(pnl_autolink, size=(200, 200), hlExe=True, name=u'al list') # Auto-Link import, generate and remove buttons btn_al_import = CreateButton(pnl_autolink, btnid.IMPORT) btn_al_remove = CreateButton(pnl_autolink, btnid.REMOVE) btn_al_generate = CreateButton(pnl_autolink, image=u'build') # Auto-Link help btn_help = CreateButton(pnl_autolink, btnid.HELP, size=64) # Initialize script display self.ScriptSelect(None) SetPageToolTips(self) # *** Event Handling *** # for DS, RB in self.script_objects: wx.EVT_RADIOBUTTON(RB, RB.GetId(), self.ScriptSelect) wx.EVT_BUTTON(btn_al_import, btnid.IMPORT, self.ImportExes) wx.EVT_BUTTON(btn_al_generate, wx.ID_ANY, self.OnGenerate) wx.EVT_BUTTON(btn_al_remove, btnid.REMOVE, self.ImportExes) wx.EVT_BUTTON(btn_help, btnid.HELP, self.OnHelpButton) # *** Layout *** # # Organizing radio buttons lyt_sel_script = BoxSizer(wx.HORIZONTAL) lyt_sel_script.AddMany(( (rb_preinst), (rb_postinst), (rb_prerm), (rb_postrm), )) # Sizer for left half of scripts panel lyt_left = BoxSizer(wx.VERTICAL) lyt_left.Add(lyt_sel_script, 0, wx.EXPAND|wx.BOTTOM, 5) for DS, RB in self.script_objects: lyt_left.Add(DS, 1, wx.EXPAND) # Auto-Link/Right side lyt_ti_autolink = BoxSizer(wx.HORIZONTAL) lyt_ti_autolink.Add(txt_autolink, 0, lyt.ALGN_C) lyt_ti_autolink.Add(self.ti_autolink, 1, lyt.ALGN_C) lyt_btn_autolink = BoxSizer(wx.HORIZONTAL) lyt_btn_autolink.Add(btn_al_import, 0) lyt_btn_autolink.Add(btn_al_remove, 0, lyt.PAD_LR, 5) lyt_btn_autolink.Add(btn_al_generate, 0) lyt_autolink = BoxSizer(wx.VERTICAL) lyt_autolink.Add(lyt_ti_autolink, 0, wx.EXPAND|lyt.PAD_LRT, 5) lyt_autolink.Add(self.Executables, 3, wx.EXPAND|lyt.PAD_LRT, 5) lyt_autolink.Add(lyt_btn_autolink, 0, lyt.ALGN_CH) lyt_autolink.Add(btn_help, 1, lyt.ALGN_C) pnl_autolink.SetSizer(lyt_autolink) pnl_autolink.SetAutoLayout(True) pnl_autolink.Layout() # Sizer for right half of scripts panel lyt_right = BoxSizer(wx.VERTICAL) # Line up panels to look even lyt_right.AddSpacer(44) lyt_right.Add(wx.StaticText(self, label=GT(u'Auto-Link Executables')), 0, lyt.ALGN_LB) lyt_right.Add(pnl_autolink, 0, wx.EXPAND) lyt_main = BoxSizer(wx.HORIZONTAL) lyt_main.Add(lyt_left, 1, wx.EXPAND|wx.ALL, 5) lyt_main.Add(lyt_right, 0, wx.ALL, 5) self.SetAutoLayout(True) self.SetSizer(lyt_main) self.Layout()
def __init__(self, parent): WizardPage.__init__(self, parent, pgid.SCRIPTS) preinst = DebianScript(self, ID_INST_PRE) postinst = DebianScript(self, ID_INST_POST) prerm = DebianScript(self, ID_RM_PRE) postrm = DebianScript(self, ID_RM_POST) # Check boxes for choosing scripts chk_preinst = CheckBox(self, ID_INST_PRE, GT(u'Make this script'), name=GT(u'Pre-Install')) preinst.SetCheckBox(chk_preinst) chk_postinst = CheckBox(self, ID_INST_POST, GT(u'Make this script'), name=GT(u'Post-Install')) postinst.SetCheckBox(chk_postinst) chk_prerm = CheckBox(self, ID_RM_PRE, GT(u'Make this script'), name=GT(u'Pre-Remove')) prerm.SetCheckBox(chk_prerm) chk_postrm = CheckBox(self, ID_RM_POST, GT(u'Make this script'), name=GT(u'Post-Remove')) postrm.SetCheckBox(chk_postrm) for S in chk_preinst, chk_postinst, chk_prerm, chk_postrm: S.SetToolTipString(u'{} {}'.format( S.GetName(), GT(u'script will be created from text below'))) S.Bind(wx.EVT_CHECKBOX, self.OnToggleScripts) # Radio buttons for displaying between pre- and post- install scripts # FIXME: Names settings for tooltips are confusing rb_preinst = wx.RadioButton(self, preinst.GetId(), GT(u'Pre-Install'), name=preinst.FileName, style=wx.RB_GROUP) rb_postinst = wx.RadioButton(self, postinst.GetId(), GT(u'Post-Install'), name=postinst.FileName) rb_prerm = wx.RadioButton(self, prerm.GetId(), GT(u'Pre-Remove'), name=prerm.FileName) rb_postrm = wx.RadioButton(self, postrm.GetId(), GT(u'Post-Remove'), name=postrm.FileName) # TODO: Remove check boxes from lists (no longer needed) self.script_objects = ( ( preinst, chk_preinst, rb_preinst, ), ( postinst, chk_postinst, rb_postinst, ), ( prerm, chk_prerm, rb_prerm, ), ( postrm, chk_postrm, rb_postrm, ), ) for DS, CHK, RB in self.script_objects: CHK.Hide() # Set script text areas to default enabled/disabled setting self.OnToggleScripts() # *** Auto-Link *** # pnl_autolink = BorderedPanel(self) # Auto-Link path for new link txt_autolink = wx.StaticText(pnl_autolink, label=GT(u'Path'), name=u'target') self.ti_autolink = PathCtrl(pnl_autolink, value=u'/usr/bin', defaultValue=u'/usr/bin', warn=True) self.ti_autolink.SetName(u'target') self.ti_autolink.Default = self.ti_autolink.GetValue() # Auto-Link executables to be linked self.Executables = BasicFileList(pnl_autolink, size=(200, 200), hlExe=True, name=u'al list') # Auto-Link import, generate and remove buttons btn_al_import = CreateButton(pnl_autolink, btnid.IMPORT) btn_al_remove = CreateButton(pnl_autolink, btnid.REMOVE) btn_al_generate = CreateButton(pnl_autolink, image=u'build') # Auto-Link help btn_help = CreateButton(pnl_autolink, btnid.HELP, size=64) # Initialize script display self.ScriptSelect(None) SetPageToolTips(self) # *** Event Handling *** # for DS, CHK, RB in self.script_objects: RB.Bind(wx.EVT_RADIOBUTTON, self.ScriptSelect) wx.EVT_BUTTON(btn_al_import, btnid.IMPORT, self.ImportExes) wx.EVT_BUTTON(btn_al_generate, wx.ID_ANY, self.OnGenerate) wx.EVT_BUTTON(btn_al_remove, btnid.REMOVE, self.ImportExes) wx.EVT_BUTTON(btn_help, btnid.HELP, self.OnHelpButton) # *** Layout *** # # Organizing radio buttons lyt_sel_script = BoxSizer(wx.HORIZONTAL) lyt_sel_script.AddMany(( (chk_preinst), (chk_postinst), (chk_prerm), (chk_postrm), )) lyt_sel_script.AddStretchSpacer(1) lyt_sel_script.AddMany(( (rb_preinst), (rb_postinst), (rb_prerm), (rb_postrm), )) # Sizer for left half of scripts panel lyt_left = BoxSizer(wx.VERTICAL) lyt_left.Add(lyt_sel_script, 0, wx.EXPAND | wx.BOTTOM, 5) for DS, CHK, RB, in self.script_objects: lyt_left.Add(DS, 1, wx.EXPAND) # Auto-Link/Right side lyt_ti_autolink = BoxSizer(wx.HORIZONTAL) lyt_ti_autolink.Add(txt_autolink, 0, lyt.ALGN_C) lyt_ti_autolink.Add(self.ti_autolink, 1, lyt.ALGN_C) lyt_btn_autolink = BoxSizer(wx.HORIZONTAL) lyt_btn_autolink.Add(btn_al_import, 0) lyt_btn_autolink.Add(btn_al_remove, 0, lyt.PAD_LR, 5) lyt_btn_autolink.Add(btn_al_generate, 0) lyt_autolink = BoxSizer(wx.VERTICAL) lyt_autolink.Add(lyt_ti_autolink, 0, wx.EXPAND | lyt.PAD_LRT, 5) lyt_autolink.Add(self.Executables, 3, wx.EXPAND | lyt.PAD_LRT, 5) lyt_autolink.Add(lyt_btn_autolink, 0, lyt.ALGN_CH) lyt_autolink.Add(btn_help, 1, lyt.ALGN_C) pnl_autolink.SetSizer(lyt_autolink) pnl_autolink.SetAutoLayout(True) pnl_autolink.Layout() # Sizer for right half of scripts panel lyt_right = BoxSizer(wx.VERTICAL) # Line up panels to look even lyt_right.AddSpacer(32) lyt_right.Add(wx.StaticText(self, label=GT(u'Auto-Link Executables')), 0, lyt.ALGN_LB) lyt_right.Add(pnl_autolink, 0, wx.EXPAND) lyt_main = BoxSizer(wx.HORIZONTAL) lyt_main.Add(lyt_left, 1, wx.EXPAND | wx.ALL, 5) lyt_main.Add(lyt_right, 0, lyt.PAD_RB, 5) self.SetAutoLayout(True) self.SetSizer(lyt_main) self.Layout()