Exemple #1
0
	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()
Exemple #2
0
    def SetModeEasy(self):
        # Add sibling panel to hold menu & rename button
        pnl_top = wx.Panel(self)

        for C in self.GetChildren():
            if isinstance(C, wx.Button):
                C.Reparent(pnl_top)

        # FIXME: Hack
        temp_bar = BorderedPanel(pnl_top)

        menubar = PanelMenuBar(temp_bar)
        menubar.HideBorder()

        menu_add = PanelMenu(menubar, label=GT(u'Add'))
        menu_add.Append(manid.SINGLE, GT(u'Single line section'))
        menu_add.Append(manid.MULTILINE, GT(u'Multi-line section'))

        menubar.AddItem(menu_add)

        self.pnl_bottom = ScrolledPanel(self)

        # *** Banners *** #

        txt_banners = wx.StaticText(self.pnl_bottom, label=GT(u'Banners'))
        banners = ManBanner(self.pnl_bottom)
        pnl_banners = banners.GetPanel()

        # *** Event Handling *** #

        wx.EVT_MENU(self, manid.SINGLE, self.OnAddDocumentSection)
        wx.EVT_MENU(self, manid.MULTILINE, self.OnAddDocumentSection)

        # *** Layout *** #

        # FIXME: Hack
        temp_lyt = BoxSizer(wx.HORIZONTAL)
        temp_lyt.Add(menubar)
        temp_lyt.AddStretchSpacer(1)

        temp_bar.SetSizer(temp_lyt)

        lyt_top = BoxSizer(wx.VERTICAL)
        lyt_top.Add(self.lyt_buttons, 0, wx.EXPAND | wx.ALL, 5)
        # FIXME: temp_bar height is initially wrong
        lyt_top.Add(temp_bar, 0, wx.EXPAND | wx.ALL, 5)

        pnl_top.SetAutoLayout(True)
        pnl_top.SetSizer(lyt_top)

        # FIXME: Use GridBagSizer???
        lyt_bottom = BoxSizer(wx.VERTICAL)
        lyt_bottom.Add(txt_banners, 0, wx.ALIGN_BOTTOM | wx.LEFT | wx.TOP, 5)
        lyt_bottom.Add(pnl_banners, 0, wx.LEFT, 5)
        lyt_bottom.AddStretchSpacer(1)

        self.pnl_bottom.SetAutoLayout(True)
        self.pnl_bottom.SetSizer(lyt_bottom)

        self.lyt_main.Add(pnl_top, 0, wx.EXPAND)
        self.lyt_main.Add(self.pnl_bottom, 1, wx.EXPAND)

        self.SetAutoLayout(True)
        self.SetSizer(self.lyt_main)

        # *** Default Sections *** #

        # This calls self.Layout
        self.AddDocumentSection(GT(u'Name'))
        self.AddDocumentSection(GT(u'Synopsis'),
                                style=DEFAULT_MANSECT_STYLE | manid.MULTILINE)
        self.AddDocumentSection(GT(u'Description'),
                                style=DEFAULT_MANSECT_STYLE | manid.MULTILINE)
        self.AddDocumentSection(GT(u'Options'),
                                style=DEFAULT_MANSECT_STYLE | manid.MULTILINE)
        self.AddDocumentSection(GT(u'Examples'),
                                style=DEFAULT_MANSECT_STYLE | manid.MULTILINE)
        self.AddDocumentSection(GT(u'See also'))
Exemple #3
0
class ManPage(wx.Panel):
    def __init__(self, parent, name=u'manual', easy_mode=True):
        wx.Panel.__init__(self, parent, name=name)

        # False is 'manual', True is 'easy'
        self.SetMode(easy_mode)

    ## Retrieves the child index that contains the object
    #
    #  \param item
    #	Object instance to search for
    #  \return
    #	\b \e Integer index of the item or -1
    def _get_object_section(self, item):
        index = 0

        for C1 in self.pnl_bottom.GetSizer().GetChildren():
            C1 = C1.GetWindow()

            if isinstance(C1, ManPanel):
                for C2 in C1.GetChildren():
                    if C2 == item:
                        return index

            index += 1

        return None

    ## Adds a new child section to the document
    #
    #  \param section_name
    #	\b \e String name of the section
    #  \param style
    #	\b \e Integer style comprised of globals.ident.mainid
    #  \return
    #	\b \e True if new section was added
    def AddDocumentSection(self,
                           section_name=None,
                           style=DEFAULT_MANSECT_STYLE):
        doc_section = ManSect(self.pnl_bottom, section_name, style=style)
        obj_section = doc_section.GetObject()

        if not obj_section:
            return False

        if doc_section.HasStyle(manid.CHOICE | manid.MUTABLE):
            labels = (GT(u'Name'), GT(u'Synopsis'), GT(u'Configuration'),
                      GT(u'Description'), GT(u'Options'), GT(u'Exit status'),
                      GT(u'Return value'), GT(u'Errors'), GT(u'Environment'),
                      GT(u'Files'), GT(u'Versions'), GT(u'Conforming to'),
                      GT(u'Notes'), GT(u'Bugs'), GT(u'Examples'),
                      GT(u'See also'))

            doc_section.Label.Set(labels)

            if section_name:
                doc_section.Label.SetStringSelection(section_name)

            if not doc_section.Label.GetSelection():
                doc_section.Label.SetSelection(0)

        if doc_section.HasStyle(manid.REMOVABLE):
            # FIXME: Replace with checkboxes
            btn_remove = doc_section.GetButton()
            if btn_remove:
                btn_remove.Bind(wx.EVT_BUTTON, self.OnRemoveDocumentSection)

        proportion = 0
        if doc_section.HasStyle(manid.MULTILINE):
            # FIXME: Proportion for multilines is not any bigger
            proportion = 2

        FLAGS = wx.LEFT | wx.RIGHT | wx.TOP

        layout = self.pnl_bottom.GetSizer()
        layout.AddKeepLast(obj_section, proportion, wx.EXPAND | FLAGS, 5)

        self.Layout()

        return True

    ## Retrieves manpage section & contents
    #
    #  \return
    #	\b \e String \b \e tuple of section name & value
    def Get(self):
        return (
            self.GetSection(),
            self.GetValue(),
        )

    ## Get the manpage section number
    #
    #  \return
    #	\b \e String section name
    def GetSection(self):
        return self.sel_section.GetStringSelection()

    ## TODO: Doxygen
    def InEasyMode(self):
        return self.EasyMode

    ## Adds a new section to the document via button press
    #
    #  \return
    #	Value of ui.manual.ManPage.AddDocumentSection
    def OnAddDocumentSection(self, event=None):
        style = DEFAULT_MANSECT_STYLE

        if event:
            event_object = event.GetEventObject()

            if isinstance(event_object, wx.Menu):
                event_id = event.GetId()

            else:
                event_id = event_object.GetId()

            if event_id == manid.MULTILINE:
                style = style | manid.MULTILINE

        return self.AddDocumentSection(style=style)

    ## Show a confirmation dialog when closing a tab
    #
    #  TODO: Find children & check default values
    def OnCloseTab(self, event=None):
        pass

    ## Removes selected section from manpage document via button press
    #
    #  \return
    #	Value of ui.manual.ManPage.RemoveDocumentSection
    def OnRemoveDocumentSection(self, event=None, index=None):
        if event:
            index = self._get_object_section(event.GetEventObject())

        return self.RemoveDocumentSection(index)

    ## Removes selected section from manpage document
    #
    #  \param index
    #	\b \e Integer index of the child section to remove
    #  \return
    #	\b \e True if section elements were removed
    def RemoveDocumentSection(self, index):
        if index == None:
            Logger.Error(__name__, u'Cannot remove desired index')

            return False

        Logger.Debug(__name__,
                     u'Removing manpage section at index {}'.format(index))

        layout = self.pnl_bottom.GetSizer()

        object_to_remove = layout.GetItem(index).GetWindow()

        # Object was returned as wx.Window instance
        if object_to_remove:
            layout.Detach(object_to_remove)
            object_to_remove.Destroy()

            self.Layout()

            return True

        return False

    ## Changes the displayed template mode
    #
    #  \b \e Easy mode dispays controls for adding individual sections. \b \e Manual
    #  mode shows a plain text area.
    #
    #  \param mode
    #	Mode to be displayed
    #	If is event object, retrieves mode from object's attribute 'Mode'
    #  \return
    #	Value of either ui.manual.ManPage.SetModeEasy or ui.manual.ManPage.SetModeManual
    def SetMode(self, mode):
        if isinstance(mode, wx.CommandEvent):
            mode = mode.GetEventObject().Mode

        self.EasyMode = mode

        # Restart with fresh panel
        # FIXME: Can be done without destroying children
        self.DestroyChildren()

        # Import/Export/Preview
        btn_browse = CreateButton(self, btnid.BROWSE)
        btn_save = CreateButton(self, btnid.SAVE)
        btn_preview = CreateButton(self, btnid.PREVIEW)

        # *** Layout *** #

        self.lyt_buttons = BoxSizer(wx.HORIZONTAL)
        self.lyt_buttons.AddStretchSpacer(1)
        self.lyt_buttons.Add(btn_browse)
        self.lyt_buttons.Add(btn_save)
        self.lyt_buttons.Add(btn_preview)

        self.lyt_main = BoxSizer(wx.VERTICAL)

        if mode:
            return self.SetModeEasy()

        return self.SetModeManual()

    ## Displays template in 'easy' mode
    #
    #  Uses controls to add & edit individual sections.
    def SetModeEasy(self):
        # Add sibling panel to hold menu & rename button
        pnl_top = wx.Panel(self)

        for C in self.GetChildren():
            if isinstance(C, wx.Button):
                C.Reparent(pnl_top)

        # FIXME: Hack
        temp_bar = BorderedPanel(pnl_top)

        menubar = PanelMenuBar(temp_bar)
        menubar.HideBorder()

        menu_add = PanelMenu(menubar, label=GT(u'Add'))
        menu_add.Append(manid.SINGLE, GT(u'Single line section'))
        menu_add.Append(manid.MULTILINE, GT(u'Multi-line section'))

        menubar.AddItem(menu_add)

        self.pnl_bottom = ScrolledPanel(self)

        # *** Banners *** #

        txt_banners = wx.StaticText(self.pnl_bottom, label=GT(u'Banners'))
        banners = ManBanner(self.pnl_bottom)
        pnl_banners = banners.GetPanel()

        # *** Event Handling *** #

        wx.EVT_MENU(self, manid.SINGLE, self.OnAddDocumentSection)
        wx.EVT_MENU(self, manid.MULTILINE, self.OnAddDocumentSection)

        # *** Layout *** #

        # FIXME: Hack
        temp_lyt = BoxSizer(wx.HORIZONTAL)
        temp_lyt.Add(menubar)
        temp_lyt.AddStretchSpacer(1)

        temp_bar.SetSizer(temp_lyt)

        lyt_top = BoxSizer(wx.VERTICAL)
        lyt_top.Add(self.lyt_buttons, 0, wx.EXPAND | wx.ALL, 5)
        # FIXME: temp_bar height is initially wrong
        lyt_top.Add(temp_bar, 0, wx.EXPAND | wx.ALL, 5)

        pnl_top.SetAutoLayout(True)
        pnl_top.SetSizer(lyt_top)

        # FIXME: Use GridBagSizer???
        lyt_bottom = BoxSizer(wx.VERTICAL)
        lyt_bottom.Add(txt_banners, 0, wx.ALIGN_BOTTOM | wx.LEFT | wx.TOP, 5)
        lyt_bottom.Add(pnl_banners, 0, wx.LEFT, 5)
        lyt_bottom.AddStretchSpacer(1)

        self.pnl_bottom.SetAutoLayout(True)
        self.pnl_bottom.SetSizer(lyt_bottom)

        self.lyt_main.Add(pnl_top, 0, wx.EXPAND)
        self.lyt_main.Add(self.pnl_bottom, 1, wx.EXPAND)

        self.SetAutoLayout(True)
        self.SetSizer(self.lyt_main)

        # *** Default Sections *** #

        # This calls self.Layout
        self.AddDocumentSection(GT(u'Name'))
        self.AddDocumentSection(GT(u'Synopsis'),
                                style=DEFAULT_MANSECT_STYLE | manid.MULTILINE)
        self.AddDocumentSection(GT(u'Description'),
                                style=DEFAULT_MANSECT_STYLE | manid.MULTILINE)
        self.AddDocumentSection(GT(u'Options'),
                                style=DEFAULT_MANSECT_STYLE | manid.MULTILINE)
        self.AddDocumentSection(GT(u'Examples'),
                                style=DEFAULT_MANSECT_STYLE | manid.MULTILINE)
        self.AddDocumentSection(GT(u'See also'))

    ## Displays template in 'manual' mode
    #
    #  Manpage document must be entered 'manually' with plain text.
    def SetModeManual(self):
        self.ManualText = TextAreaPanel(self)

        # *** Layout *** #

        self.lyt_main.Add(self.lyt_buttons, 0, wx.EXPAND | wx.ALL, 5)
        self.lyt_main.Add(self.ManualText, 1, wx.EXPAND)

        self.SetAutoLayout(True)
        self.SetSizer(self.lyt_main)
        self.Layout()
Exemple #4
0
 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()
Exemple #5
0
    def __init__(self, parent):
        WizardPage.__init__(self, parent, pgid.COPYRIGHT)

        self.custom_licenses = []

        ## A list of available license templates
        self.sel_templates = Choice(self, selid.LICENSE, name=u'list»')

        # Initialize the template list
        self.OnRefreshList()

        btn_template = CreateButton(self,
                                    label=GT(u'Full Template'),
                                    image=u'full',
                                    name=u'full»')
        self.btn_template_simple = CreateButton(self,
                                                label=GT(u'Short Template'),
                                                image=u'short',
                                                name=u'short»')
        btn_refresh = CreateButton(self,
                                   btnid.REFRESH,
                                   GT(u'Refresh Template List'),
                                   u'refresh',
                                   name=u'btn refresh')
        btn_open = CreateButton(self,
                                btnid.BROWSE,
                                GT(u'Open Template Directory'),
                                u'browse',
                                name=u'btn opendir',
                                commands=u'xdg-open')

        if not self.sel_templates.GetCount():
            self.sel_templates.Enable(False)
            btn_template.Enable(False)
            self.btn_template_simple.Enable(False)

        ## Area where license text is displayed
        self.dsp_copyright = TextAreaPanelESS(self,
                                              monospace=True,
                                              name=u'license')
        self.dsp_copyright.EnableDropTarget()

        SetPageToolTips(self)

        # Initiate tooltip for drop-down selector
        if self.sel_templates.IsEnabled():
            self.OnSelectLicense(self.sel_templates)

        # *** Event Handling *** #

        self.sel_templates.Bind(wx.EVT_CHOICE, self.OnSelectLicense)

        btn_open.Bind(wx.EVT_BUTTON, self.OnOpenPath)
        btn_refresh.Bind(wx.EVT_BUTTON, self.OnRefreshList)
        btn_template.Bind(wx.EVT_BUTTON, self.OnTemplateFull)
        self.btn_template_simple.Bind(wx.EVT_BUTTON, self.OnTemplateShort)

        # *** Layout *** #

        lyt_top = BoxSizer(wx.HORIZONTAL)
        lyt_top.Add(wx.StaticText(self, label=GT(u'Available Templates')), 0,
                    lyt.ALGN_CV)
        lyt_top.Add(self.sel_templates, 0, lyt.ALGN_CV | wx.LEFT, 5)
        lyt_top.Add(btn_template, 0, wx.LEFT, 5)
        lyt_top.Add(self.btn_template_simple)
        lyt_top.Add(btn_refresh)
        lyt_top.Add(btn_open)

        lyt_main = BoxSizer(wx.VERTICAL)
        lyt_main.AddSpacer(10)
        lyt_main.Add(lyt_top, 0, lyt.PAD_LR | wx.BOTTOM, 5)
        lyt_main.Add(self.dsp_copyright, 1, wx.EXPAND | lyt.PAD_LRB, 5)

        self.SetAutoLayout(True)
        self.SetSizer(lyt_main)
        self.Layout()
Exemple #6
0
    def __init__(self, parent):
        wx.Dialog.__init__(self,
                           parent,
                           title=GT(u'Quick Build'),
                           pos=wx.DefaultPosition,
                           size=wx.Size(400, 260))
        ModuleAccessCtrl.__init__(self, __name__)

        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
Exemple #7
0
    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()
Exemple #8
0
    def __init__(self, parent):
        ManSectBase.__init__(self, parent)

        self.Panel = BorderedPanel(parent)

        txt_section = wx.StaticText(self.Panel, label=GT(u'Section'))

        self.sel_section = Choice(self.Panel, choices=tuple(sections))
        self.sel_section.Default = u'1'
        self.sel_section.SetStringSelection(self.sel_section.Default)

        # Section description that changes with EVT_CHOICE
        self.LabelSection = wx.StaticText(self.Panel)
        self.SetSectionLabel()

        txt_date = wx.StaticText(self.Panel, label=GT(u'Date'))
        spin_year = wx.SpinCtrl(self.Panel,
                                min=1900,
                                max=2100,
                                initial=GetYear(string_value=False))
        spin_month = wx.SpinCtrl(self.Panel,
                                 min=1,
                                 max=12,
                                 initial=GetMonthInt())
        spin_day = wx.SpinCtrl(self.Panel, min=1, max=31, initial=GetDayInt())

        # FIXME: What is this for?
        txt_unknown1 = wx.StaticText(self.Panel, label=GT(u'Unknown'))
        ti_unknown1 = wx.TextCtrl(self.Panel)

        # FIXME: What is this for?
        txt_unknown2 = wx.StaticText(self.Panel, label=GT(u'Unknown'))
        ti_unknown2 = wx.TextCtrl(self.Panel)

        # *** Event Handling *** #

        self.sel_section.Bind(wx.EVT_CHOICE, self.OnSetSection)

        # *** Layout *** #

        lyt_section = BoxSizer(wx.HORIZONTAL)
        lyt_section.Add(txt_section, 0, wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER,
                        5)
        lyt_section.Add(self.sel_section, 0,
                        wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER, 5)
        lyt_section.Add(self.LabelSection, 0,
                        wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER, 5)

        lyt_date = wx.GridBagSizer()
        lyt_date.Add(txt_date, (1, 0), flag=wx.ALIGN_CENTER_VERTICAL)
        lyt_date.Add(wx.StaticText(self.Panel, label=GT(u'Year')), (0, 1))
        lyt_date.Add(wx.StaticText(self.Panel, label=GT(u'Month')), (0, 2))
        lyt_date.Add(wx.StaticText(self.Panel, label=GT(u'Day')), (0, 3))
        lyt_date.Add(spin_year, (1, 1), flag=wx.LEFT, border=5)
        lyt_date.Add(spin_month, (1, 2))
        lyt_date.Add(spin_day, (1, 3))

        lyt_uknwn1 = BoxSizer(wx.HORIZONTAL)
        lyt_uknwn1.Add(txt_unknown1, 0, wx.ALIGN_CENTER_VERTICAL)
        lyt_uknwn1.Add(ti_unknown1, 0, wx.LEFT, 5)

        lyt_uknwn2 = BoxSizer(wx.HORIZONTAL)
        lyt_uknwn2.Add(txt_unknown2, 0, wx.ALIGN_CENTER_VERTICAL)
        lyt_uknwn2.Add(ti_unknown2, 0, wx.LEFT, 5)

        # Change orientation of main sizer to vertical
        self.lyt_main = BoxSizer(wx.VERTICAL)
        self.lyt_main.Add(lyt_section, 0, wx.TOP, 5)
        self.lyt_main.Add(lyt_date, 0, wx.TOP, 5)
        self.lyt_main.Add(lyt_uknwn1, 0, wx.TOP, 5)
        self.lyt_main.Add(lyt_uknwn2, 0, wx.TOP, 5)

        self.Panel.SetSizer(self.lyt_main)
Exemple #9
0
    def __init__(self, pos, size):
        wx.Frame.__init__(self, None, wx.ID_ANY, default_title, pos, size)

        # Make sure that this frame is set as the top window
        if not wx.GetApp().GetTopWindow() == self:
            Logger.Debug(__name__,
                         GT(u'Setting MainWindow instance as top window'))

            wx.GetApp().SetTopWindow(self)

        testing = u'alpha' in GetTestList() or DebugEnabled()

        if DebugEnabled():
            self.SetTitle(u'{} ({})'.format(default_title, GT(u'debugging')))

        self.SetMinSize(wx.Size(640, 400))

        # ----- Set Titlebar Icon
        self.SetIcon(Icon(LOGO))

        # *** Status Bar *** #
        StatusBar(self)

        # *** Menus *** #
        menubar = MenuBar(self)

        menu_file = wx.Menu()

        menubar.Append(menu_file, GT(u'File'), menuid.FILE)
        # This menu is filled from wiz.wizard.Wizard.SetPages
        menubar.Append(wx.Menu(), GT(u'Page'), menuid.PAGE)

        # *** File Menu *** #

        mitems_file = [
            (
                menuid.NEW,
                GT(u'New project'),
                GT(u'Start a new project'),
            ),
            (
                menuid.OPEN,
                GT(u'Open'),
                GT(u'Open a previously saved project'),
            ),
            (
                menuid.SAVE,
                GT(u'Save'),
                GT(u'Save current project'),
            ),
            (
                menuid.SAVEAS,
                GT(u'Save as'),
                GT(u'Save current project with a new filename'),
            ),
            None,
            (
                menuid.QBUILD,
                GT(u'Quick Build'),
                GT(u'Build a package from an existing build tree'),
                ICON_CLOCK,
            ),
            None,
            (
                menuid.EXIT,
                GT(u'Quit'),
                GT(u'Exit Debreate'),
            ),
        ]

        if testing:
            mitems_file.append((menuid.ALIEN, GT(u'Convert packages'),
                                GT(u'Convert between package types')))

        # Adding all menus to menu bar

        mitems = (mitems_file, )

        for menu_list in mitems:
            for mitem in menu_list:
                if not mitem:
                    menu_file.AppendSeparator()

                else:
                    itm = wx.MenuItem(menu_file, mitem[0], mitem[1], mitem[2])
                    if len(mitem) > 3:
                        itm.SetBitmap(mitem[3])

                    menu_file.AppendItem(itm)

        # *** Action Menu *** #
        menu_action = wx.Menu()

        mitm_build = wx.MenuItem(menu_action, menuid.BUILD, GT(u'Build'),
                                 GT(u'Start building .deb package'))

        menu_action.AppendItem(mitm_build)

        # ----- Options Menu
        menu_opt = wx.Menu()

        # Show/Hide tooltips
        self.opt_tooltips = wx.MenuItem(menu_opt,
                                        menuid.TOOLTIPS,
                                        GT(u'Show tooltips'),
                                        GT(u'Show or hide tooltips'),
                                        kind=wx.ITEM_CHECK)

        # A bug with wx 2.8 does not allow tooltips to be toggled off
        if wx.MAJOR_VERSION > 2:
            menu_opt.AppendItem(self.opt_tooltips)

        if menu_opt.FindItemById(menuid.TOOLTIPS):
            show_tooltips = ReadConfig(u'tooltips')
            if show_tooltips != ConfCode.KEY_NO_EXIST:
                self.opt_tooltips.Check(show_tooltips)

            else:
                self.opt_tooltips.Check(GetDefaultConfigValue(u'tooltips'))

            self.OnToggleToolTips()

        # Project compression options
        self.menu_compress = wx.Menu()

        opt_z_none = wx.MenuItem(
            self.menu_compress,
            ident.ZIP_NONE,
            GT(u'Uncompressed'),
            GT(u'Use uncompressed tarball for project save format'),
            kind=wx.ITEM_RADIO)
        opt_z_gz = wx.MenuItem(
            self.menu_compress,
            ident.ZIP_GZ,
            GT(u'Gzip'),
            GT(u'Use compressed Gzip tarball for project save format'),
            kind=wx.ITEM_RADIO)
        opt_z_bz2 = wx.MenuItem(
            self.menu_compress,
            ident.ZIP_BZ2,
            GT(u'Bzip2'),
            GT(u'Use compressed Bzip2 tarball for project save format'),
            kind=wx.ITEM_RADIO)
        opt_z_zip = wx.MenuItem(
            self.menu_compress,
            ident.ZIP_ZIP,
            GT(u'Zip'),
            GT(u'Use compressed zip file for project save format'),
            kind=wx.ITEM_RADIO)

        opts_compress = [
            opt_z_none,
            opt_z_gz,
            opt_z_bz2,
            opt_z_zip,
        ]

        if GetExecutable(u'tar') != None:
            opt_z_xz = wx.MenuItem(
                self.menu_compress,
                ident.ZIP_XZ,
                GT(u'XZ'),
                GT(u'Use compressed xz tarball for project save format'),
                kind=wx.ITEM_RADIO)
            opts_compress.insert(3, opt_z_xz)

        for OPT in opts_compress:
            self.menu_compress.AppendItem(OPT)
            wx.EVT_MENU(self.menu_compress, OPT.GetId(), self.OnSetCompression)

        # Default compression
        self.menu_compress.Check(ident.ZIP_BZ2, True)

        menu_opt.AppendSubMenu(
            self.menu_compress, GT(u'Project Compression'),
            GT(u'Set the compression type for project save output'))

        # *** Option Menu: open logs directory *** #

        if GetExecutable(u'xdg-open'):
            mitm_logs_open = wx.MenuItem(menu_opt, menuid.OPENLOGS,
                                         GT(u'Open logs directory'))
            menu_opt.AppendItem(mitm_logs_open)

            wx.EVT_MENU(menu_opt, menuid.OPENLOGS, self.OnLogDirOpen)

        # *** OS distribution names cache *** #

        opt_distname_cache = wx.MenuItem(
            menu_opt, menuid.DIST, GT(u'Update dist names cache'),
            GT(u'Creates/Updates list of distribution names for changelog page'
               ))
        menu_opt.AppendItem(opt_distname_cache)

        # ----- Help Menu
        menu_help = wx.Menu()

        # ----- Version update
        mitm_update = wx.MenuItem(
            menu_help, menuid.UPDATE, GT(u'Check for update'),
            GT(u'Check if a new version is available for download'))
        mitm_update.SetBitmap(ICON_LOGO)

        menu_help.AppendItem(mitm_update)
        menu_help.AppendSeparator()

        # Menu with links to the Debian Policy Manual webpages
        self.menu_policy = wx.Menu()

        policy_links = (
            (
                refid.DPM,
                GT(u'Debian Policy Manual'),
                u'https://www.debian.org/doc/debian-policy',
            ),
            (
                refid.DPMCtrl,
                GT(u'Control files'),
                u'https://www.debian.org/doc/debian-policy/ch-controlfields.html',
            ),
            (
                refid.DPMLog,
                GT(u'Changelog'),
                u'https://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog',
            ),
            (
                refid.UPM,
                GT(u'Ubuntu Policy Manual'),
                u'http://people.canonical.com/~cjwatson/ubuntu-policy/policy.html/',
            ),
            (
                refid.LINT_TAGS,
                GT(u'Lintian Tags Explanation'),
                u'https://lintian.debian.org/tags-all.html',
            ),
            (
                refid.LINT_OVERRIDE,
                GT(u'Overriding Lintian Tags'),
                u'https://lintian.debian.org/manual/section-2.4.html',
            ),
            (
                refid.LAUNCHERS,
                GT(u'Launchers / Desktop entries'),
                u'https://www.freedesktop.org/wiki/Specifications/desktop-entry-spec/',
            ),
            # Unofficial links
            None,
            (
                refid.DEBSRC,
                GT(u'Building debs from Source'),
                u'http://www.quietearth.us/articles/2006/08/16/Building-deb-package-from-source',
            ),  # This is here only temporarily for reference
            (
                refid.MAN,
                GT(u'Writing manual pages'),
                u'https://liw.fi/manpages/',
            ),
        )

        for LINK in policy_links:
            if not LINK:
                self.menu_policy.AppendSeparator()

            elif len(LINK) > 2:
                link_id = LINK[0]
                label = LINK[1]
                url = LINK[2]

                if len(LINK) > 3:
                    icon = LINK[3]

                else:
                    icon = ICON_GLOBE

                mitm = wx.MenuItem(self.menu_policy, link_id, label, url)
                mitm.SetBitmap(icon)
                self.menu_policy.AppendItem(mitm)

                wx.EVT_MENU(self, link_id, self.OpenPolicyManual)

        mitm_help = wx.MenuItem(menu_help, wx.ID_HELP, GT(u'Help'),
                                GT(u'Open a usage document'))
        mitm_about = wx.MenuItem(menu_help, wx.ID_ABOUT, GT(u'About'),
                                 GT(u'About Debreate'))

        menu_help.AppendMenu(-1, GT(u'Reference'), self.menu_policy)
        menu_help.AppendSeparator()
        menu_help.AppendItem(mitm_help)
        menu_help.AppendItem(mitm_about)

        menubar.Append(menu_action, GT(u'Action'), menuid.ACTION)

        if menu_opt.GetMenuItemCount():
            menubar.Append(menu_opt, GT(u'Options'), menuid.OPTIONS)

        menubar.Append(menu_help, GT(u'Help'), menuid.HELP)

        self.Wizard = Wizard(self)

        # Menu for debugging & running tests
        if DebugEnabled():
            self.menu_debug = wx.Menu()

            menubar.Append(self.menu_debug, GT(u'Debug'), menuid.DEBUG)

            self.menu_debug.AppendItem(
                wx.MenuItem(self.menu_debug,
                            menuid.LOG,
                            GT(u'Show log'),
                            GT(u'Toggle debug log window'),
                            kind=wx.ITEM_CHECK))

            if u'log-window' in parsed_args_s:
                self.menu_debug.Check(menuid.LOG, True)

            self.log_window = None

            # Window colors
            self.menu_debug.AppendItem(
                wx.MenuItem(self.menu_debug, menuid.THEME,
                            GT(u'Toggle window colors')))

            wx.EVT_MENU(self, menuid.THEME, self.OnToggleTheme)

        # *** Current Project Status *** #

        self.LoadedProject = None
        self.ProjectDirty = False
        self.dirty_mark = u' *'

        menu_file.Enable(wx.ID_SAVE, self.ProjectDirty)

        # *** Event Handling *** #

        wx.EVT_MENU(self, menuid.NEW, self.OnProjectNew)
        wx.EVT_MENU(self, menuid.OPEN, self.OnProjectOpen)
        wx.EVT_MENU(self, menuid.SAVE, self.OnProjectSave)
        wx.EVT_MENU(self, menuid.SAVEAS, self.OnProjectSaveAs)
        wx.EVT_MENU(self, menuid.QBUILD, self.OnQuickBuild)
        wx.EVT_MENU(self, menuid.EXIT, self.OnQuit)

        wx.EVT_MENU(self, menuid.TOOLTIPS, self.OnToggleToolTips)
        wx.EVT_MENU(self, menuid.DIST, self.OnUpdateDistNamesCache)

        wx.EVT_MENU(self, menuid.UPDATE, self.OnCheckUpdate)
        wx.EVT_MENU(self, menuid.HELP, self.OnHelp)
        wx.EVT_MENU(self, menuid.ABOUT, self.OnAbout)

        self.Bind(EVT_CHANGE_PAGE, self.OnWizardBtnPage)

        # Custom close event shows a dialog box to confirm quit
        wx.EVT_CLOSE(self, self.OnQuit)

        # *** Layout *** #

        lyt_main = BoxSizer(wx.VERTICAL)
        lyt_main.Add(self.Wizard, 1, wx.EXPAND)

        self.SetAutoLayout(True)
        self.SetSizer(lyt_main)
        self.Layout()
Exemple #10
0
    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()
Exemple #11
0
class ManBanner(ManSectBase):
    def __init__(self, parent):
        ManSectBase.__init__(self, parent)

        self.Panel = BorderedPanel(parent)

        txt_section = wx.StaticText(self.Panel, label=GT(u'Section'))

        self.sel_section = Choice(self.Panel, choices=tuple(sections))
        self.sel_section.Default = u'1'
        self.sel_section.SetStringSelection(self.sel_section.Default)

        # Section description that changes with EVT_CHOICE
        self.LabelSection = wx.StaticText(self.Panel)
        self.SetSectionLabel()

        txt_date = wx.StaticText(self.Panel, label=GT(u'Date'))
        spin_year = wx.SpinCtrl(self.Panel,
                                min=1900,
                                max=2100,
                                initial=GetYear(string_value=False))
        spin_month = wx.SpinCtrl(self.Panel,
                                 min=1,
                                 max=12,
                                 initial=GetMonthInt())
        spin_day = wx.SpinCtrl(self.Panel, min=1, max=31, initial=GetDayInt())

        # FIXME: What is this for?
        txt_unknown1 = wx.StaticText(self.Panel, label=GT(u'Unknown'))
        ti_unknown1 = wx.TextCtrl(self.Panel)

        # FIXME: What is this for?
        txt_unknown2 = wx.StaticText(self.Panel, label=GT(u'Unknown'))
        ti_unknown2 = wx.TextCtrl(self.Panel)

        # *** Event Handling *** #

        self.sel_section.Bind(wx.EVT_CHOICE, self.OnSetSection)

        # *** Layout *** #

        lyt_section = BoxSizer(wx.HORIZONTAL)
        lyt_section.Add(txt_section, 0, wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER,
                        5)
        lyt_section.Add(self.sel_section, 0,
                        wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER, 5)
        lyt_section.Add(self.LabelSection, 0,
                        wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER, 5)

        lyt_date = wx.GridBagSizer()
        lyt_date.Add(txt_date, (1, 0), flag=wx.ALIGN_CENTER_VERTICAL)
        lyt_date.Add(wx.StaticText(self.Panel, label=GT(u'Year')), (0, 1))
        lyt_date.Add(wx.StaticText(self.Panel, label=GT(u'Month')), (0, 2))
        lyt_date.Add(wx.StaticText(self.Panel, label=GT(u'Day')), (0, 3))
        lyt_date.Add(spin_year, (1, 1), flag=wx.LEFT, border=5)
        lyt_date.Add(spin_month, (1, 2))
        lyt_date.Add(spin_day, (1, 3))

        lyt_uknwn1 = BoxSizer(wx.HORIZONTAL)
        lyt_uknwn1.Add(txt_unknown1, 0, wx.ALIGN_CENTER_VERTICAL)
        lyt_uknwn1.Add(ti_unknown1, 0, wx.LEFT, 5)

        lyt_uknwn2 = BoxSizer(wx.HORIZONTAL)
        lyt_uknwn2.Add(txt_unknown2, 0, wx.ALIGN_CENTER_VERTICAL)
        lyt_uknwn2.Add(ti_unknown2, 0, wx.LEFT, 5)

        # Change orientation of main sizer to vertical
        self.lyt_main = BoxSizer(wx.VERTICAL)
        self.lyt_main.Add(lyt_section, 0, wx.TOP, 5)
        self.lyt_main.Add(lyt_date, 0, wx.TOP, 5)
        self.lyt_main.Add(lyt_uknwn1, 0, wx.TOP, 5)
        self.lyt_main.Add(lyt_uknwn2, 0, wx.TOP, 5)

        self.Panel.SetSizer(self.lyt_main)

    ## Retrieve main object instance
    def GetPanel(self):
        return self.Panel

    ## TODO: Doxygen
    def OnSetSection(self, event=None):
        self.SetSectionLabel(self.sel_section.GetStringSelection())

    ## Updates the label for the current section
    def SetSectionLabel(self, section=None):
        if section == None:
            section = self.sel_section.GetStringSelection()

        if section in sections:
            Logger.Debug(__name__, u'Setting section to {}'.format(section))

            self.LabelSection.SetLabel(sections[section])
            return True

        return False
Exemple #12
0
class ListCtrl(BorderedPanel, ControlPanel):
    def __init__(self,
                 parent,
                 win_id=wx.ID_ANY,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.LC_ICON,
                 validator=wx.DefaultValidator,
                 name=wx.ListCtrlNameStr,
                 defaultValue=None,
                 required=False,
                 outLabel=None):

        BorderedPanel.__init__(self, parent, win_id, pos, size, name=name)

        if isinstance(self, EssentialField):
            self.MainCtrl = ListCtrlBaseESS(self,
                                            style=style,
                                            validator=validator,
                                            defaultValue=defaultValue,
                                            required=required,
                                            outLabel=outLabel)

        else:
            self.MainCtrl = ListCtrlBase(self,
                                         style=style,
                                         validator=validator,
                                         defaultValue=defaultValue,
                                         required=required,
                                         outLabel=outLabel)

        # Match panel background color to list control
        self.SetBackgroundColour(self.MainCtrl.GetBackgroundColour())

        self.layout_V1 = BoxSizer(wx.VERTICAL)
        self.layout_V1.Add(self.MainCtrl, 1, wx.EXPAND)

        self.SetAutoLayout(True)
        self.SetSizer(self.layout_V1)
        self.Layout()

        if wx.MAJOR_VERSION == 3 and wx.MINOR_VERSION == 0:
            wx.EVT_SIZE(self, self.OnResize)

    ## TODO: Doxygen
    def AppendColumn(self, heading, fmt=wx.LIST_FORMAT_LEFT, width=-1):
        self.MainCtrl.AppendColumn(heading, fmt, width)

    ## TODO: Doxygen
    def AppendStringItem(self, items):
        self.MainCtrl.AppendStringItem(items)

    ## TODO: Doxygen
    def Arrange(self, flag=wx.LIST_ALIGN_DEFAULT):
        self.MainCtrl.Arrange(flag)

    ## TODO: Doxygen
    def ClearAll(self):
        self.MainCtrl.ClearAll()

    ## Removes all columns from the main control
    #
    #  \return
    #	ListCtrlBase.DeleteAllColumns
    def DeleteAllColumns(self):
        return self.MainCtrl.DeleteAllColumns()

    ## TODO: Doxygen
    def DeleteAllItems(self):
        self.MainCtrl.DeleteAllItems()

    ## TODO: Doxygen
    def DeleteItem(self, item):
        self.MainCtrl.DeleteItem(item)

    ## Disables the panel & list control
    def Disable(self, *args, **kwargs):
        self.MainCtrl.Disable(*args, **kwargs)

        return BorderedPanel.Disable(self, *args, **kwargs)

    ## TODO: Doxygen
    def EditLabel(self, item):
        self.MainCtrl.EditLabel(item)

    ## Enables/Disables the panel & list control
    def Enable(self, *args, **kwargs):
        self.MainCtrl.Enable(*args, **kwargs)

        return BorderedPanel.Enable(self, *args, **kwargs)

    ## TODO: Doxygen
    def GetColumnCount(self):
        return self.MainCtrl.GetColumnCount()

    ## Retrieves the string label of a given column
    def GetColumnLabel(self, col):
        return self.MainCtrl.GetColumnLabel(col)

    ## Retrieves labels for all columns
    #
    #  \return
    #	<b><i>String</i></b> list of all column labels
    def GetColumnLabels(self):
        return self.MainCtrl.GetColumnLabels()

    ## TODO: Doxygen
    def GetColumnWidth(self, col):
        return self.MainCtrl.GetColumnWidth(col)

    ## Retrieves number of files in list
    def GetCount(self):
        return self.GetItemCount()

    ## TODO: Doxygen
    def GetCountPerPage(self):
        return self.MainCtrl.GetCountPerPage()

    ## TODO: Doxygen
    def GetFirstSelected(self):
        return self.MainCtrl.GetFirstSelected()

    ## TODO: Doxygen
    def GetFocusedItem(self):
        return self.MainCtrl.GetFocusedItem()

    ## TODO: Doxygen
    def GetItem(self, row, col):
        return self.MainCtrl.GetItem(row, col)

    ## TODO: Doxygen
    def GetItemCount(self):
        return self.MainCtrl.GetItemCount()

    ## TODO: Doxygen
    def GetItemText(self, item, col=0):
        if wx.MAJOR_VERSION > 2:
            return self.MainCtrl.GetItemText(item, col)

        return self.MainCtrl.GetItem(item, col).GetText()

    ## TODO: Doxygen
    def GetItemTextColour(self, item):
        return self.MainCtrl.GetItemTextColour(item)

    ## TODO: Doxygen
    def GetListCtrl(self):
        return self.MainCtrl

    ## Retrieve a tuple list of contents
    def GetListTuple(self, col=0, typeTuple=True):
        return self.MainCtrl.GetListTuple(col, typeTuple)

    ## TODO: Doxygen
    def GetNextItem(self,
                    item,
                    geometry=wx.LIST_NEXT_ALL,
                    state=wx.LIST_STATE_DONTCARE):
        return self.MainCtrl.GetNextItem(item, geometry, state)

    ## TODO: Doxygen
    def GetNextSelected(self, item):
        self.MainCtrl.GetNextSelected(item)

    ## TODO: Doxygen
    def GetPanelStyle(self, *args, **kwargs):
        return BorderedPanel.GetWindowStyle(self, *args, **kwargs)

    ## TODO: Doxygen
    def GetPanelStyleFlag(self, *args, **kwargs):
        return BorderedPanel.GetWindowStyleFlag(self, *args, **kwargs)

    ## TODO: Doxygen
    def GetSelectedIndexes(self):
        return self.MainCtrl.GetSelectedIndexes()

    ## TODO: Doxygen
    def GetSelectedItemCount(self):
        return self.MainCtrl.GetSelectedItemCount()

    ## TODO: Doxygen
    def GetWindowStyle(self):
        return self.MainCtrl.GetWindowStyle()

    ## TODO: Doxygen
    def GetWindowStyleFlag(self):
        return self.MainCtrl.GetWindowStyleFlag()

    ## TODO: Doxygen
    def HitTest(self, point, flags, ptrSubItem=None):
        return self.MainCtrl.HitTest(point, flags, ptrSubItem)

    ## TODO: Doxygen
    def InsertColumn(self,
                     col,
                     heading,
                     fmt=wx.LIST_FORMAT_LEFT,
                     width=wx.LIST_AUTOSIZE):
        self.MainCtrl.InsertColumn(col, heading, fmt, width)

    ## TODO: Doxygen
    #
    #  FIXME: imageIndex unused; Unknown purpose, not documented
    def InsertStringItem(self, index, label, imageIndex=None):
        self.MainCtrl.InsertStringItem(index, label)

    ## Checks if field is required for building
    def IsRequired(self):
        return self.MainCtrl.IsRequired()

    ## Some bug workarounds for resizing the list & its columns in wx 3.0
    #
    #  The last column is automatically expanded to fill
    #	the remaining space.
    #  FIXME: Unknown if this bug persists in wx 3.1
    def OnResize(self, event=None):
        if (self.GetWindowStyleFlag()) & wx.LC_REPORT:
            # FIXME: -10 should be a dynamic number set by the sizer's padding
            self.SetSize(wx.Size(self.GetParent().Size[0] - 10, self.Size[1]))

        if event:
            event.Skip()

    ## TODO: Doxygen
    def RemoveSelected(self):
        self.MainCtrl.RemoveSelected()

    ## Resets the list to default values
    def Reset(self):
        return self.MainCtrl.Reset()

    ## Sets the string label for a given column
    def SetColumnLabel(self, col, label):
        return self.MainCtrl.SetColumnLabel(col, label)

    ## Sets list's column count & labels
    #
    #  \param labels
    #	List of string labels for column headers
    #  \param colWidth
    #	<b><i>Integer</b></i> width of each column
    def SetColumns(self, labels, colWidth):
        return self.MainCtrl.SetColumns(labels, colWidth)

    ## TODO: Doxygen
    def SetColumnWidth(self, col, width):
        self.MainCtrl.SetColumnWidth(col, width)
        self.MainCtrl.Layout()

    ## TODO: Doxygen
    def SetItemBackgroundColour(self, item, color):
        self.MainCtrl.SetItemBackgroundColour(item, color)

    ## TODO: Doxygen
    def SetItemTextColour(self, item, color):
        self.MainCtrl.SetItemTextColour(item, color)

    ## TODO: Doxygen
    def SetPanelStyle(self, *args, **kwargs):
        return BorderedPanel.SetWindowStyle(self, *args, **kwargs)

    ## TODO: Doxygen
    def SetPanelStyleFlag(self, *args, **kwargs):
        return BorderedPanel.SetWindowStyleFlag(self, *args, **kwargs)

    ## TODO: Doxygen
    def SetSingleStyle(self, *args, **kwargs):
        self.MainCtrl.SetSingleStyle(*args, **kwargs)

    ## TODO: Doxygen
    #
    #  FIXME: imageId unused; Unknown purpose, not documented
    def SetStringItem(self, index, col, label, imageId=None):
        self.MainCtrl.SetStringItem(index, col, label)

    ## TODO: Doxygen
    def SetWindowStyle(self, *args, **kwargs):
        return self.MainCtrl.SetWindowStyle(*args, **kwargs)

    ## TODO: Doxygen
    def SetWindowStyleFlag(self, *args, **kwargs):
        return self.MainCtrl.SetWindowStyleFlag(*args, **kwargs)
Exemple #13
0
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
Exemple #14
0
    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()
Exemple #15
0
    def __init__(self, parent):
        WizardPage.__init__(self, parent, pgid.BUILD)

        # ----- Extra Options

        pnl_options = BorderedPanel(self)

        self.chk_md5 = CheckBoxESS(pnl_options,
                                   chkid.MD5,
                                   GT(u'Create md5sums file'),
                                   name=u'MD5',
                                   defaultValue=True,
                                   commands=u'md5sum')
        # The » character denotes that an alternate tooltip should be shown if the control is disabled
        self.chk_md5.tt_name = u'md5»'
        self.chk_md5.col = 0

        # Option to strip binaries
        self.chk_strip = CheckBoxESS(pnl_options,
                                     chkid.STRIP,
                                     GT(u'Strip binaries'),
                                     name=u'strip»',
                                     defaultValue=True,
                                     commands=u'strip')
        self.chk_strip.col = 0

        # Deletes the temporary build tree
        self.chk_rmstage = CheckBoxESS(pnl_options,
                                       chkid.DELETE,
                                       GT(u'Delete staged directory'),
                                       name=u'RMSTAGE',
                                       defaultValue=True)
        self.chk_rmstage.col = 0

        # Checks the output .deb for errors
        self.chk_lint = CheckBoxESS(
            pnl_options,
            chkid.LINT,
            GT(u'Check package for errors with lintian'),
            name=u'LINTIAN',
            defaultValue=True,
            commands=u'lintian')
        self.chk_lint.tt_name = u'lintian»'
        self.chk_lint.col = 0

        # Installs the deb on the system
        self.chk_install = CheckBox(pnl_options,
                                    chkid.INSTALL,
                                    GT(u'Install package after build'),
                                    name=u'INSTALL',
                                    commands=(
                                        u'gdebi-gtk',
                                        u'gdebi-kde',
                                    ))
        self.chk_install.tt_name = u'install»'
        self.chk_install.col = 0

        # *** Lintian Overrides *** #

        if UsingTest(u'alpha'):
            # FIXME: Move next to lintian check box
            Logger.Info(__name__,
                        u'Enabling alpha feature "lintian overrides" option')
            self.lint_overrides = []
            btn_lint_overrides = CreateButton(self,
                                              label=GT(u'Lintian overrides'))
            btn_lint_overrides.Bind(wx.EVT_BUTTON, self.OnSetLintOverrides)

        btn_build = CreateButton(self, btnid.BUILD, GT(u'Build'), u'build', 64)

        # Display log
        dsp_log = OutputLog(self)

        SetPageToolTips(self)

        # *** Event Handling *** #

        btn_build.Bind(wx.EVT_BUTTON, self.OnBuild)

        # *** Layout *** #

        lyt_options = wx.GridBagSizer()

        next_row = 0
        prev_row = next_row
        for CHK in pnl_options.Children:
            row = next_row
            FLAGS = lyt.PAD_LR

            if CHK.col:
                row = prev_row
                FLAGS = wx.RIGHT

            lyt_options.Add(CHK, (row, CHK.col), flag=FLAGS, border=5)

            if not CHK.col:
                prev_row = next_row
                next_row += 1

        pnl_options.SetSizer(lyt_options)
        pnl_options.SetAutoLayout(True)
        pnl_options.Layout()

        lyt_buttons = BoxSizer(wx.HORIZONTAL)
        lyt_buttons.Add(btn_build, 1)

        lyt_main = BoxSizer(wx.VERTICAL)
        lyt_main.AddSpacer(10)
        lyt_main.Add(wx.StaticText(self, label=GT(u'Extra Options')), 0,
                     lyt.ALGN_LB | wx.LEFT, 5)
        lyt_main.Add(pnl_options, 0, wx.LEFT, 5)
        lyt_main.AddSpacer(5)

        if UsingTest(u'alpha'):
            #lyt_main.Add(wx.StaticText(self, label=GT(u'Lintian overrides')), 0, wx.LEFT, 5)
            lyt_main.Add(btn_lint_overrides, 0, wx.LEFT, 5)

        lyt_main.AddSpacer(5)
        lyt_main.Add(lyt_buttons, 0, lyt.ALGN_C)
        lyt_main.Add(dsp_log, 2, wx.EXPAND | lyt.PAD_LRB, 5)

        self.SetAutoLayout(True)
        self.SetSizer(lyt_main)
        self.Layout()
Exemple #16
0
    def __init__(self, parent):
        WizardPage.__init__(self, parent, pgid.FILES)

        # *** Left Panel *** #

        pnl_treeopts = BorderedPanel(self)

        self.chk_individuals = CheckBoxCFG(
            pnl_treeopts,
            label=GT(u'List files individually'),
            name=u'individually',
            cfgSect=u'FILES')

        self.chk_preserve_top = CheckBoxCFG(
            pnl_treeopts,
            label=GT(u'Preserve top-level directories'),
            name=u'top-level',
            cfgSect=u'FILES')

        self.tree_dirs = DirectoryTreePanel(self, size=(300, 20))

        # ----- Target path
        pnl_target = BorderedPanel(self)

        # choices of destination
        rb_bin = wx.RadioButton(pnl_target, label=u'/bin', style=wx.RB_GROUP)
        rb_usrbin = wx.RadioButton(pnl_target, label=u'/usr/bin')
        rb_usrlib = wx.RadioButton(pnl_target, label=u'/usr/lib')
        rb_locbin = wx.RadioButton(pnl_target, label=u'/usr/local/bin')
        rb_loclib = wx.RadioButton(pnl_target, label=u'/usr/local/lib')
        self.rb_custom = wx.RadioButton(pnl_target, inputid.CUSTOM,
                                        GT(u'Custom'))
        self.rb_custom.Default = True

        # Start with "Custom" selected
        self.rb_custom.SetValue(self.rb_custom.Default)

        # group buttons together
        # FIXME: Unnecessary???
        self.grp_targets = (
            rb_bin,
            rb_usrbin,
            rb_usrlib,
            rb_locbin,
            rb_loclib,
            self.rb_custom,
        )

        # ----- Add/Remove/Clear buttons
        btn_add = CreateButton(self, btnid.ADD)
        btn_remove = CreateButton(self, btnid.REMOVE)
        btn_clear = CreateButton(self, btnid.CLEAR)

        self.prev_dest_value = u'/usr/bin'
        self.ti_target = TextArea(self,
                                  defaultValue=self.prev_dest_value,
                                  name=u'target')

        self.btn_browse = CreateButton(self, btnid.BROWSE)
        btn_refresh = CreateButton(self, btnid.REFRESH)

        # Display area for files added to list
        self.lst_files = FileListESS(self, inputid.LIST, name=u'filelist')

        # *** Event Handling *** #

        # create an event to enable/disable custom widget
        for item in self.grp_targets:
            wx.EVT_RADIOBUTTON(item, wx.ID_ANY, self.OnSetDestination)

        # Context menu events for directory tree
        wx.EVT_MENU(self, wx.ID_ADD, self.OnImportFromTree)

        # Button events
        btn_add.Bind(wx.EVT_BUTTON, self.OnImportFromTree)
        btn_remove.Bind(wx.EVT_BUTTON, self.OnRemoveSelected)
        btn_clear.Bind(wx.EVT_BUTTON, self.OnClearFileList)
        self.btn_browse.Bind(wx.EVT_BUTTON, self.OnBrowse)
        btn_refresh.Bind(wx.EVT_BUTTON, self.OnRefreshFileList)

        # ???: Not sure what these do
        wx.EVT_KEY_DOWN(self.ti_target, self.GetDestValue)
        wx.EVT_KEY_UP(self.ti_target, self.CheckDest)

        # Key events for file list
        wx.EVT_KEY_DOWN(self.lst_files, self.OnRemoveSelected)

        self.Bind(wx.EVT_DROP_FILES, self.OnDropFiles)

        # *** Layout *** #

        lyt_treeopts = BoxSizer(wx.VERTICAL)
        lyt_treeopts.AddSpacer(5)
        lyt_treeopts.Add(self.chk_individuals, 0, lyt.PAD_LR, 5)
        lyt_treeopts.Add(self.chk_preserve_top, 0, lyt.PAD_LR, 5)
        lyt_treeopts.AddSpacer(5)

        pnl_treeopts.SetSizer(lyt_treeopts)

        lyt_left = BoxSizer(wx.VERTICAL)
        lyt_left.AddSpacer(10)
        lyt_left.Add(wx.StaticText(self, label=GT(u'Directory options')), 0,
                     wx.ALIGN_BOTTOM)
        lyt_left.Add(pnl_treeopts, 0, wx.EXPAND | wx.ALIGN_LEFT | wx.BOTTOM, 5)
        lyt_left.Add(self.tree_dirs, 1, wx.EXPAND)

        lyt_target = wx.GridSizer(3, 2, 5, 5)

        for item in self.grp_targets:
            lyt_target.Add(item, 0, lyt.PAD_LR, 5)

        pnl_target.SetAutoLayout(True)
        pnl_target.SetSizer(lyt_target)
        pnl_target.Layout()

        # Put text input in its own sizer to force expand
        lyt_input = BoxSizer(wx.HORIZONTAL)
        lyt_input.Add(self.ti_target, 1, wx.ALIGN_CENTER_VERTICAL)

        lyt_buttons = BoxSizer(wx.HORIZONTAL)
        lyt_buttons.Add(btn_add, 0)
        lyt_buttons.Add(btn_remove, 0)
        lyt_buttons.Add(btn_clear, 0)
        lyt_buttons.Add(lyt_input, 1, wx.ALIGN_CENTER_VERTICAL)
        lyt_buttons.Add(self.btn_browse, 0)
        lyt_buttons.Add(btn_refresh, 0)

        lyt_right = BoxSizer(wx.VERTICAL)
        lyt_right.AddSpacer(10)
        lyt_right.Add(wx.StaticText(self, label=GT(u'Target')))
        lyt_right.Add(pnl_target, 0, wx.TOP, 5)
        lyt_right.Add(lyt_buttons, 0, wx.EXPAND)
        lyt_right.Add(self.lst_files, 5, wx.EXPAND | wx.TOP, 5)

        PROP_LEFT = 0
        PROP_RIGHT = 1

        lyt_main = wx.FlexGridSizer(1, 2)
        lyt_main.AddGrowableRow(0)

        # Directory tree size issues with wx 2.8
        if wx.MAJOR_VERSION <= 2:
            PROP_LEFT = 1
            lyt_main.AddGrowableCol(0, 1)

        lyt_main.AddGrowableCol(1, 2)
        lyt_main.Add(lyt_left, PROP_LEFT, wx.EXPAND | lyt.PAD_LR | wx.BOTTOM,
                     5)
        lyt_main.Add(lyt_right, PROP_RIGHT, wx.EXPAND | lyt.PAD_RB, 5)

        self.SetAutoLayout(True)
        self.SetSizer(lyt_main)
        self.Layout()

        SetPageToolTips(self)
Exemple #17
0
    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()

        if OS_name:
            os_info = wx.StaticText(sys_info, label=OS_name)
            os_info.SetFont(sys_info_font)

            if OS_version:
                os_info.SetLabel(u'{} {}'.format(os_info.LabelText,
                                                 OS_version))

            if OS_codename:
                os_info.SetLabel(u'{} {}'.format(os_info.LabelText,
                                                 OS_codename))

            sysinfo_layout_V1.Insert(1, os_info, 0,
                                     wx.ALIGN_CENTER | wx.BOTTOM, 5)
            sysinfo_layout_V1.InsertSpacer(2, 20)

            if OS_upstream_name:
                os_upstream_info = wx.StaticText(sys_info,
                                                 label=OS_upstream_name)

                if OS_upstream_version:
                    os_upstream_info.SetLabel(u'{} {}'.format(
                        os_upstream_info.LabelText, OS_upstream_version))

                if OS_upstream_codename:
                    os_upstream_info.SetLabel(u'{} {}'.format(
                        os_upstream_info.LabelText, OS_upstream_codename))

                sysinfo_layout_V1.Insert(2, os_upstream_info, 0,
                                         wx.ALIGN_CENTER | wx.BOTTOM, 5)

        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()
Exemple #18
0
    def __init__(self):
        BaseDialog.__init__(self,
                            title=GT(u'Update Dist Names Cache'),
                            style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        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()
Exemple #19
0
    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()
Exemple #20
0
	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()