我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用wx.LI_HORIZONTAL。
def __init__(self, parent, id, title, message, download_url, size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, name='dialog'): wx.Dialog.__init__(self, parent, id, title, pos, size, style, name) label = wx.StaticText(self, label=message) button = wx.Button(self, id=wx.ID_OK, label="Close") button.SetDefault() line = wx.StaticLine(self, wx.ID_ANY, size=(20, -1), style=wx.LI_HORIZONTAL) download_ctrl = hl.HyperLinkCtrl(self, wx.ID_ANY, download_url, URL=download_url) sizer = wx.BoxSizer(wx.VERTICAL) button_sizer = wx.StdDialogButtonSizer() button_sizer.AddButton(button) button_sizer.Realize() sizer.Add(label, 0, wx.ALIGN_CENTER|wx.ALL, 5) sizer.Add(download_ctrl, 0, wx.ALL, 10) sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) sizer.Add(button_sizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) self.SetSizer(sizer) sizer.Fit(self)
def __init__(self): wx.Frame.__init__(self, None, wx.ID_ANY, title='Testcase') v_sizer = wx.BoxSizer(wx.VERTICAL) v_sizer.Add(wx.StaticText(self, -1, "Some misc information"), 0) v_sizer.AddSpacer((0, 20), 0) v_sizer.Add(FilePicker(self), 0, wx.EXPAND) v_sizer.AddSpacer((0, 0), 1, wx.EXPAND) sticky_history = [os.path.expanduser('~'), os.path.expanduser('~/Dropbox'), os.path.expanduser('~/Documents')] v_sizer.Add(wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL), 0, wx.EXPAND|wx.ALL, 5) file_picker1 = FilePicker(self, allow_glob_matching=True, title='glob match') v_sizer.Add(file_picker1, 0, wx.EXPAND) history = sticky_history[:] v_sizer.Add(wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL), 0, wx.EXPAND|wx.ALL, 5) self.dir_picker = FilePicker(self, is_files_not_dirs=False, history=history) self.file_picker = FilePicker(self, assumed_prefix=os.path.expanduser('~/'), allow_glob_matching=True, title='glob match') self.dir_picker.on_load = self.file_picker.set_assumed_prefix self.file_picker.on_load = self.file_picker_on_load v_sizer.Add(self.dir_picker, 0, wx.EXPAND) v_sizer.AddSpacer((0, 10), 0, wx.EXPAND) v_sizer.Add(self.file_picker, 0, wx.EXPAND) v_sizer.Add(wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL), 0, wx.EXPAND|wx.ALL, 5) v_sizer.AddSpacer((0, 0), 1, wx.EXPAND) v_sizer.Add(FilePicker(self, sticky_history=sticky_history), 0, wx.EXPAND) v_sizer.AddSpacer((0, 0), 1, wx.EXPAND) self.SetSizer(v_sizer)
def __init__( self, parent ): wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = 'ImagePy', size = wx.Size(-1,-1), pos = wx.DefaultPosition, style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) logopath = os.path.join(root_dir, 'data/logo.ico') #self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_3DLIGHT ) ) self.SetIcon(wx.Icon(logopath, wx.BITMAP_TYPE_ICO)) self.SetSizeHints( wx.Size( 600,-1 ), wx.DefaultSize ) IPy.curapp = self # Todo:Fixed absolute/relative path! # print("menuspath:{}".format( os.path.join(root_dir,"menus"))) # print("toolspath:{}".format(os.path.join(root_dir,"tools")) # menuspath = os.path.join(root_dir, "menus") # toolspath = os.path.join(root_dir,"tools") self.menubar = pluginloader.buildMenuBarByPath(self, 'menus') self.SetMenuBar( self.menubar ) self.shortcut = pluginloader.buildShortcut(self) self.SetAcceleratorTable(self.shortcut) sizer = wx.BoxSizer(wx.VERTICAL) self.toolbar = toolsloader.build_tools(self, 'tools') #self.toolbar.Realize() #sizertool.Add(self.toolbar, 1, 0, 5 ) #sizertool.Add(self.morebar, 0, 0, 5) sizer.Add(self.toolbar, 0, wx.EXPAND, 5 ) #sizer.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 ) self.line_color = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) #self.line_color.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_HIGHLIGHT ) ) sizer.AddStretchSpacer(prop=1) sizer.Add(self.line_color, 0, wx.EXPAND |wx.ALL, 0 ) stapanel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) sizersta = wx.BoxSizer( wx.HORIZONTAL ) self.txt_info = wx.StaticText( stapanel, wx.ID_ANY, "ImagePy v0.2", wx.DefaultPosition, wx.DefaultSize, 0 ) self.txt_info.Wrap( -1 ) #self.txt_info.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_INFOBK ) ) sizersta.Add( self.txt_info, 1, wx.ALIGN_BOTTOM|wx.BOTTOM|wx.LEFT|wx.RIGHT, 2 ) self.pro_bar = wx.Gauge( stapanel, wx.ID_ANY, 100, wx.DefaultPosition, wx.Size( 100,15 ), wx.GA_HORIZONTAL ) sizersta.Add( self.pro_bar, 0, wx.ALIGN_BOTTOM|wx.BOTTOM|wx.LEFT|wx.RIGHT, 2 ) stapanel.SetSizer(sizersta) stapanel.SetDropTarget(FileDrop()) sizer.Add(stapanel, 0, wx.EXPAND, 5 ) self.SetSizer( sizer ) self.Centre( wx.BOTH ) self.Layout() self.Fit() self.update = False self.Bind(wx.EVT_CLOSE, self.on_close) thread = threading.Thread(None, self.hold, ()) thread.setDaemon(True) thread.start()
def create_wxwindow(self): if self.thickness is not None: if self.style & wx.LI_HORIZONTAL: self.size = (-1, self.thickness) elif self.style & wx.LI_VERTICAL: self.size = (self.thickness, -1) return self.initfn(wx.StaticLine)(self.parent, self.id, self.pos, self.size, self.style, self.name)
def __init__( self, parent, ID, title, size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, fields=None, data=None, ): wx.Dialog.__init__ (self, parent, ID, title, pos, size, style) sizer = wx.BoxSizer(wx.VERTICAL) self.textctrls = {} for field in fields: box = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, field) label.SetHelpText("This is the help text for the label") box.Add(label, 1, wx.ALIGN_CENTRE|wx.ALL, 5) text = wx.TextCtrl(self, -1, "", size=(80,-1)) text.SetHelpText("Here's some help text for field #1") if field in data: text.SetValue(repr(data[field])) box.Add(text, 1, wx.ALIGN_CENTRE|wx.ALL, 1) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 1) self.textctrls[field] = text line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) btnsizer = wx.StdDialogButtonSizer() btn = wx.Button(self, wx.ID_OK) btn.SetHelpText("The OK button completes the dialog") btn.SetDefault() btnsizer.AddButton(btn) btn = wx.Button(self, wx.ID_CANCEL) btn.SetHelpText("The Cancel button cancels the dialog. (Cool, huh?)") btnsizer.AddButton(btn) btnsizer.Realize() sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) self.SetSizer(sizer) sizer.Fit(self)
def InitUI(self): self.panel = wx.Panel(self, wx.ID_ANY) # Info Text infotext = _(u'Close all open Applications, it is possible that programs will be closed without a warning ' u'and system could reboot without further confirmation.') infobox = wx.StaticBox(self.panel, -1, _(u'Attention')) infoboxbsizer = wx.StaticBoxSizer(infobox, wx.VERTICAL) info = wx.StaticText(self.panel, label=infotext) info.Wrap(380) infoboxbsizer.Add(info, 0) self.gauge = wx.Gauge(self.panel, size=(24, 26)) self.update_label = wx.StaticText(self.panel, label=_(u'Current Progress:')) self.update_box = wx.TextCtrl(self.panel, style=wx.TE_READONLY) self.update_box.SetBackgroundColour(wx.WHITE) self.chk_shutdown = wx.CheckBox(self.panel, size=(160,20), label=_(u"Shutdown after update")) self.logButton = wx.Button(self.panel, size=(54,26), label="LOG") self.logButton.SetToolTip(wx.ToolTip(_(u'Open WPKG Log'))) self.logButton.SetBitmap(img.get('log')) self.startButton = wx.Button(self.panel, label=_(u"Update")) self.abortButton = wx.Button(self.panel, label=_(u"Cancel")) self.logButton.Disable() self.abortButton.Disable() self.line = wx.StaticLine(self.panel, -1, size=(2,2), style=wx.LI_HORIZONTAL) self.startButton.Bind(wx.EVT_BUTTON, self.OnStartButton) self.abortButton.Bind(wx.EVT_BUTTON, self.OnAbortButton) self.logButton.Bind(wx.EVT_BUTTON, self.OnLogButton) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer2 = wx.BoxSizer(wx.HORIZONTAL) self.sizer.Add(infoboxbsizer, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.gauge, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.update_label, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.update_box, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.line, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.chk_shutdown, 0, wx.LEFT | wx.EXPAND, 7) self.sizer2.Add(self.logButton, 0) self.sizer2.AddStretchSpacer() self.sizer2.Add(self.startButton, 0)#, wx.RIGHT, 2) self.sizer2.Add(self.abortButton, 0) self.sizer.Add(self.sizer2, 0, wx.ALL | wx.EXPAND, 5) self.panel.SetSizerAndFit(self.sizer) self.Center()
def __init__(self, add_book, *args, **kwargs): """ initilizer for the main from for the AddressBook app. :param add_book: the address book class to manipulate :type add_book: A address_book_data.AddressBook instance """ kwargs.setdefault('title', "Micro Address Book") wx.Frame.__init__(self, *args, **kwargs) self.add_book = add_book self.current_index = 0 # creae a status bar for messages... self.CreateStatusBar() # create the entryPanel self.entryPanel = AddBookForm(add_book.book[self.current_index], self) # put them in a Sizer to lay out S = wx.BoxSizer(wx.VERTICAL) S.Add(wx.StaticLine(self,style=wx.LI_HORIZONTAL), 0, wx.EXPAND) S.Add(self.entryPanel, 0, wx.ALL|wx.EXPAND, 4) S.Add((1,5)) S.Add(wx.StaticLine(self,style=wx.LI_HORIZONTAL), 0, wx.EXPAND) self.SetSizerAndFit(S) # Build up the menu bar: menuBar = wx.MenuBar() fileMenu = wx.Menu() closeMenuItem = fileMenu.Append(wx.ID_EXIT, "&Close", "Close the file" ) self.Bind(wx.EVT_MENU, self.onClose, closeMenuItem) exitMenuItem = fileMenu.Append(wx.ID_EXIT, "Exit", "Exit the application") self.Bind(wx.EVT_MENU, self.onExit, exitMenuItem) menuBar.Append(fileMenu, "&File") helpMenu = wx.Menu() helpMenuItem = helpMenu.Append(wx.ID_HELP, "Help", "Get help") menuBar.Append(helpMenu, "&Help") self.SetMenuBar(menuBar)