Python wx.CENTER Examples
The following are 15
code examples of wx.CENTER().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
wx
, or try the search function
.
Example #1
Source File: FileBrowseButton.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def createDialog(self, parent, id, pos, size, style, name=""): """ Setup the graphic representation of the dialog """ wx.Panel.__init__(self, parent, id, pos, size, style, name) self.SetMinSize(size) # play nice with sizers box = wx.BoxSizer(wx.HORIZONTAL) self.textControl = self.createTextControl() box.Add(self.textControl, 1, wx.CENTER, 5) self.browseButton = self.createBrowseButton() box.Add(self.browseButton, 0, wx.LEFT | wx.CENTER, 5) self.SetAutoLayout(True) self.SetSizer(box) self.Layout() if isinstance(size, tuple): size = apply(wx.Size, size) self.SetDimensions( -1, -1, size.width, size.height, wx.SIZE_USE_EXISTING )
Example #2
Source File: WordWrapRenderer.py From bookhub with MIT License | 6 votes |
def OnPaint(self, evt): dc = wx.PaintDC(self) inset = (20, 20, 20, 20) rect = [inset[0], inset[1], self.GetSize().width-(inset[0]+inset[2]), self.GetSize().height-(inset[1]+inset[3])] # Calculate exactly how high the wrapped is going to be and put a frame around it. dc.SetFont(self.font) dc.SetPen(wx.RED_PEN) rect[3] = WordWrapRenderer.CalculateHeight(dc, self.text, rect[2]) dc.DrawRectangle(*rect) WordWrapRenderer.DrawString(dc, self.text, rect, wx.ALIGN_LEFT) #WordWrapRenderer.DrawTruncatedString(dc, self.text, rect, wx.ALIGN_CENTER_HORIZONTAL,s ellipse=wx.CENTER) #bmp = wx.EmptyBitmap(rect[0]+rect[2], rect[1]+rect[3]) #mdc = wx.MemoryDC(bmp) #mdc.SetBackground(wx.Brush("white")) #mdc.Clear() #mdc.SetFont(self.font) #mdc.SetPen(wx.RED_PEN) #rect[3] = WordWrapRenderer.CalculateHeight(mdc, self.text, rect[2]) #mdc.DrawRectangle(*rect) #WordWrapRenderer.DrawString(mdc, self.text, rect, wx.ALIGN_LEFT) #del mdc #dc = wx.ScreenDC() #dc.DrawBitmap(bmp, 20, 20)
Example #3
Source File: configuration_dialogs.py From superpaper with MIT License | 5 votes |
def create_bottom_butts(self): """Create sizer for bottom row buttons.""" self.sizer_buttons = wx.BoxSizer(wx.HORIZONTAL) self.button_align_test = wx.Button(self, label="Align test") self.button_test_pick = wx.Button(self, label="Pick image") self.button_test_imag = wx.Button(self, label="Test image") self.button_ok = wx.Button(self, label="OK") self.button_cancel = wx.Button(self, label="Close") self.button_align_test.Bind(wx.EVT_BUTTON, self.onAlignTest) self.button_test_pick.Bind(wx.EVT_BUTTON, self.onChooseTestImage) self.button_test_imag.Bind(wx.EVT_BUTTON, self.onTestWallpaper) self.button_ok.Bind(wx.EVT_BUTTON, self.onOk) self.button_cancel.Bind(wx.EVT_BUTTON, self.onCancel) self.sizer_buttons.Add(self.button_align_test, 0, wx.CENTER|wx.ALL, 5) sline = wx.StaticLine(self, -1, style=wx.LI_VERTICAL) self.sizer_buttons.Add(sline, 0, wx.EXPAND|wx.ALL, 5) self.tc_testimage = wx.TextCtrl(self, -1, size=(self.tc_width, -1)) self.sizer_buttons.Add(self.tc_testimage, 0, wx.CENTER|wx.ALL, 5) self.sizer_buttons.Add(self.button_test_pick, 0, wx.CENTER|wx.ALL, 5) self.sizer_buttons.Add(self.button_test_imag, 0, wx.CENTER|wx.ALL, 5) self.sizer_buttons.AddStretchSpacer() self.sizer_buttons.Add(self.button_ok, 0, wx.CENTER|wx.ALL, 5) self.sizer_buttons.Add(self.button_cancel, 0, wx.CENTER|wx.ALL, 5)
Example #4
Source File: gui.py From superpaper with MIT License | 5 votes |
def create_sizer_profiles(self): # choice menu self.list_of_profiles = list_profiles() self.profnames = [] for prof in self.list_of_profiles: self.profnames.append(prof.name) self.profnames.append("Create a new profile") self.choice_profiles = wx.Choice(self, -1, name="ProfileChoice", choices=self.profnames) self.choice_profiles.Bind(wx.EVT_CHOICE, self.onSelect) st_choice_profiles = wx.StaticText(self, -1, "Setting profiles:") # name txt ctrl st_name = wx.StaticText(self, -1, "Profile name:") self.tc_name = wx.TextCtrl(self, -1, size=(self.tc_width, -1)) self.tc_name.SetMaxLength(14) # buttons self.button_new = wx.Button(self, label="New") self.button_save = wx.Button(self, label="Save") self.button_delete = wx.Button(self, label="Delete") self.button_new.Bind(wx.EVT_BUTTON, self.onCreateNewProfile) self.button_save.Bind(wx.EVT_BUTTON, self.onSave) self.button_delete.Bind(wx.EVT_BUTTON, self.onDeleteProfile) # Add elements to the sizer self.sizer_profiles.Add(st_choice_profiles, 0, wx.CENTER|wx.ALL, 5) self.sizer_profiles.Add(self.choice_profiles, 0, wx.CENTER|wx.ALL, 5) self.sizer_profiles.Add(st_name, 0, wx.CENTER|wx.ALL, 5) self.sizer_profiles.Add(self.tc_name, 0, wx.CENTER|wx.ALL, 5) self.sizer_profiles.Add(self.button_new, 0, wx.CENTER|wx.ALL, 5) self.sizer_profiles.Add(self.button_save, 0, wx.CENTER|wx.ALL, 5) self.sizer_profiles.Add(self.button_delete, 0, wx.CENTER|wx.ALL, 5)
Example #5
Source File: gui.py From superpaper with MIT License | 5 votes |
def create_sizer_paths(self): self.sizer_setting_paths = wx.StaticBoxSizer(wx.VERTICAL, self, "Wallpaper paths") self.statbox_parent_paths = self.sizer_setting_paths.GetStaticBox() st_paths_info = wx.StaticText(self.statbox_parent_paths, -1, "Browse to add your wallpaper files or source folders here:") if self.use_multi_image: self.path_listctrl = wx.ListCtrl(self.statbox_parent_paths, -1, style=wx.LC_REPORT | wx.BORDER_SIMPLE | wx.LC_SORT_ASCENDING ) self.path_listctrl.InsertColumn(0, 'Display', wx.LIST_FORMAT_RIGHT, width = 100) self.path_listctrl.InsertColumn(1, 'Source', width = 400) else: # show simpler listing without header if only one wallpaper target self.path_listctrl = wx.ListCtrl(self.statbox_parent_paths, -1, style=wx.LC_REPORT | wx.BORDER_SIMPLE | wx.LC_NO_HEADER ) self.path_listctrl.InsertColumn(0, 'Source', width = 500) self.path_listctrl.SetImageList(self.image_list, wx.IMAGE_LIST_SMALL) self.sizer_setting_paths.Add(st_paths_info, 0, wx.ALIGN_LEFT|wx.ALL, 5) self.sizer_setting_paths.Add( self.path_listctrl, 1, wx.CENTER|wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, 5 ) # Buttons self.sizer_setting_paths_buttons = wx.BoxSizer(wx.HORIZONTAL) self.button_browse = wx.Button(self.statbox_parent_paths, label="Browse") self.button_remove_source = wx.Button(self.statbox_parent_paths, label="Remove selected source") self.button_browse.Bind(wx.EVT_BUTTON, self.onBrowsePaths) self.button_remove_source.Bind(wx.EVT_BUTTON, self.onRemoveSource) self.sizer_setting_paths_buttons.Add(self.button_browse, 0, wx.CENTER|wx.ALL, 5) self.sizer_setting_paths_buttons.Add(self.button_remove_source, 0, wx.CENTER|wx.ALL, 5) # add button sizer to parent paths sizer self.sizer_setting_paths.Add(self.sizer_setting_paths_buttons, 0, wx.CENTER|wx.EXPAND|wx.ALL, 0) self.sizer_settings_right.Add( self.sizer_setting_paths, 1, wx.CENTER|wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, 5 )
Example #6
Source File: app.py From thotkeeper with BSD 2-Clause "Simplified" License | 5 votes |
def _HelpAboutMenu(self, event): wx.MessageBox((f'ThotKeeper - a personal daily journal application.\n' f'\n' f'Copyright (c) 2004-2020 C. Michael Pilato. ' f'All rights reserved.\n' f'\n' f'ThotKeeper is open source software developed under ' f'the BSD License. Question, comments, and code ' f'contributions are welcome.\n' f'\n' f'Website: http://www.thotkeeper.org/\n' f'Version: {__version__}\n'), 'About ThotKeeper', wx.OK | wx.CENTER, self.frame)
Example #7
Source File: main.py From wxGlade with MIT License | 5 votes |
def open_from_history(self, event): if not self.ask_save(): return pos = event.GetId() - wx.ID_FILE1 filename = self.file_history.GetHistoryFile(pos) if not os.path.exists(filename): wx.MessageBox( _("The file %s doesn't exist.") % filename, _('Information'), style=wx.CENTER | wx.ICON_INFORMATION | wx.OK ) self.file_history.RemoveFileFromHistory(pos) common.remove_autosaved(filename) return self._open(filename)
Example #8
Source File: WordWrapRenderer.py From bookhub with MIT License | 5 votes |
def _Truncate(dc, text, maxWidth, ellipse, ellipseChars): """ Return a string that will fit within the given width. """ line = text.split("\n")[0] # only consider the first line if not line: return "" pte = dc.GetPartialTextExtents(line) # Does the whole thing fit within our given width? stringWidth = pte[-1] if stringWidth <= maxWidth: return line # We (probably) have to ellipse the text so allow for ellipse maxWidthMinusEllipse = maxWidth - dc.GetTextExtent(ellipseChars)[0] if ellipse == wx.LEFT: i = bisect.bisect(pte, stringWidth - maxWidthMinusEllipse) return ellipseChars + line[i+1:] if ellipse == wx.CENTER: i = bisect.bisect(pte, maxWidthMinusEllipse / 2) j = bisect.bisect(pte, stringWidth - maxWidthMinusEllipse / 2) return line[:i] + ellipseChars + line[j+1:] if ellipse == wx.RIGHT: i = bisect.bisect(pte, maxWidthMinusEllipse) return line[:i] + ellipseChars # No ellipsing, just truncating is the default i = bisect.bisect(pte, maxWidth) return line[:i] #====================================================================== # TESTING ONLY #======================================================================
Example #9
Source File: ListCtrlPrinter.py From bookhub with MIT License | 5 votes |
def __init__(self, image=None, horizontalAlign=wx.CENTER, verticalAlign=wx.CENTER, over=True): """ image must be either an wx.Image or a wx.Bitmap """ self.horizontalAlign = horizontalAlign self.verticalAlign = verticalAlign self.over = True self.bitmap = image if isinstance(image, wx.Image): self.bitmap = wx.BitmapFromImage(image)
Example #10
Source File: viewer_low_level_util.py From dials with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, outer_panel, i_bmp_in): super(multi_img_scrollable, self).__init__(outer_panel) self.parent_panel = outer_panel self.lst_2d_bmp = i_bmp_in self.SetBackgroundColour(wx.Colour(200, 200, 200)) self.mainSizer = wx.BoxSizer(wx.VERTICAL) self.n_img = 0 self.img_lst_v_sizer = wx.BoxSizer(wx.VERTICAL) self.set_scroll_content() self.mainSizer.Add(self.img_lst_v_sizer, 0, wx.CENTER | wx.ALL, 10) self.SetSizer(self.mainSizer) self.SetupScrolling() self.SetScrollRate(1, 1) self.Mouse_Pos_x = -1 self.Mouse_Pos_y = -1 self.old_Mouse_Pos_x = -1 self.old_Mouse_Pos_y = -1 self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel) self.Bind(wx.EVT_MOTION, self.OnMouseMotion) self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftButDown) self.Bind(wx.EVT_LEFT_UP, self.OnLeftButUp) self.Bind(wx.EVT_IDLE, self.OnIdle) self.scroll_rot = 0
Example #11
Source File: viewer_low_level_util.py From dials with BSD 3-Clause "New" or "Revised" License | 5 votes |
def set_scroll_content(self): self.img_lst_v_sizer.Clear(True) for lst_1d in self.lst_2d_bmp: img_lst_hor_sizer = wx.BoxSizer(wx.HORIZONTAL) for i, i_bmp in enumerate(lst_1d): local_bitmap = wx.StaticBitmap(self, bitmap=i_bmp) if self.parent_panel.local_bbox is None: slice_string = "Slice[" + str(i) + ":" + str(i + 1) + ", :, :]" else: bbx = self.parent_panel.local_bbox slice_string = "Image # " + str(bbx[4] + i) slice_sub_info_txt = wx.StaticText(self, -1, slice_string) sigle_slice_sizer = wx.BoxSizer(wx.VERTICAL) sigle_slice_sizer.Clear(True) sigle_slice_sizer.Add( local_bitmap, proportion=0, flag=wx.ALIGN_CENTRE | wx.ALL, border=2 ) sigle_slice_sizer.Add( slice_sub_info_txt, proportion=0, flag=wx.ALIGN_CENTRE | wx.ALL, border=2, ) img_lst_hor_sizer.Add( sigle_slice_sizer, proportion=0, flag=wx.ALIGN_CENTER | wx.ALL, border=2, ) self.img_lst_v_sizer.Add(img_lst_hor_sizer, 0, wx.CENTER | wx.ALL, 10) self.n_img += 1 self.parent_panel.Pframe.Layout() self.SetScrollRate(1, 1)
Example #12
Source File: autosetup_tty.py From openplotter with GNU General Public License v2.0 | 4 votes |
def __init__(self): self.serial = 0 self.conf = Conf() Language(self.conf) wx.Frame.__init__(self, None, wx.ID_ANY, _('tty auto setup'), size=(720, 350)) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) log = wx.TextCtrl(panel, wx.ID_ANY, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL) self.autostart = wx.CheckBox(panel, label=_('setup autostart on every boot')) self.autostart.Bind(wx.EVT_CHECKBOX, self.on_autostart) setup = wx.Button(panel, wx.ID_ANY, 'setup') setup.Bind(wx.EVT_BUTTON, on_setup) close = wx.Button(panel, wx.ID_CLOSE) close.Bind(wx.EVT_BUTTON, self.on_close) # Add widgets to a sizer hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(self.autostart, 0, wx.ALL | wx.EXPAND, 5) hbox.Add((0, 0), 1, wx.ALL | wx.EXPAND, 5) hbox.Add(setup, 0, wx.ALL | wx.EXPAND, 5) hbox.Add(close, 0, wx.ALL | wx.EXPAND, 5) vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(log, 1, wx.ALL | wx.EXPAND, 5) vbox.Add(hbox, 0, wx.ALL | wx.CENTER | wx.EXPAND, 5) panel.SetSizer(vbox) self.tool_list = [] data = self.conf.get('TOOLS', 'py') try: temp_list = eval(data) except: temp_list = [] for ii in temp_list: self.tool_list.append(ii) self.tool = [] self.tool_exist = False for i in self.tool_list: if i[2] == 'autosetup_tty.py': self.autostart.SetValue(i[3] == '1') self.tool.append(i) self.tool_exist = True # redirect text here redir = RedirectText(log) sys.stdout = redir print _('Auto setup detects hardware. Please make sure that all devices are turned on.') print
Example #13
Source File: configuration_dialogs.py From superpaper with MIT License | 4 votes |
def create_paths_listctrl(self, use_multi_image): if use_multi_image: self.paths_listctrl = wx.ListCtrl(self, -1, size=(-1, -1), style=wx.LC_REPORT # | wx.BORDER_SUNKEN | wx.BORDER_SIMPLE # | wx.BORDER_STATIC # | wx.BORDER_THEME # | wx.BORDER_NONE # | wx.LC_EDIT_LABELS | wx.LC_SORT_ASCENDING # | wx.LC_NO_HEADER # | wx.LC_VRULES # | wx.LC_HRULES # | wx.LC_SINGLE_SEL ) self.paths_listctrl.InsertColumn(0, 'Display', wx.LIST_FORMAT_RIGHT, width=100) self.paths_listctrl.InsertColumn(1, 'Source', width=620) else: # show simpler listing without header if only one wallpaper target self.paths_listctrl = wx.ListCtrl(self, -1, size=(-1, -1), style=wx.LC_REPORT # | wx.BORDER_SUNKEN | wx.BORDER_SIMPLE # | wx.BORDER_STATIC # | wx.BORDER_THEME # | wx.BORDER_NONE # | wx.LC_EDIT_LABELS # | wx.LC_SORT_ASCENDING | wx.LC_NO_HEADER # | wx.LC_VRULES # | wx.LC_HRULES # | wx.LC_SINGLE_SEL ) self.paths_listctrl.InsertColumn(0, 'Source', width=720) # Add the item list to the control self.paths_listctrl.SetImageList(self.il, wx.IMAGE_LIST_SMALL) self.sizer_paths_list.Add(self.paths_listctrl, 1, wx.CENTER|wx.ALL|wx.EXPAND, 5)
Example #14
Source File: configuration_dialogs.py From superpaper with MIT License | 4 votes |
def __init__(self, parent, parent_tray_obj): wx.Panel.__init__(self, parent) self.frame = parent self.parent_tray_obj = parent_tray_obj self.sizer_main = wx.BoxSizer(wx.VERTICAL) self.sizer_grid_settings = wx.GridSizer(6, 2, 5, 5) self.sizer_buttons = wx.BoxSizer(wx.HORIZONTAL) pnl = self st_logging = wx.StaticText(pnl, -1, "Logging") st_usehotkeys = wx.StaticText(pnl, -1, "Use hotkeys") st_warn_large = wx.StaticText(pnl, -1, "Large image warning") st_hk_next = wx.StaticText(pnl, -1, "Hotkey: Next wallpaper") st_hk_pause = wx.StaticText(pnl, -1, "Hotkey: Pause slideshow") st_setcmd = wx.StaticText(pnl, -1, "Custom command") self.cb_logging = wx.CheckBox(pnl, -1, "") self.cb_usehotkeys = wx.CheckBox(pnl, -1, "") self.cb_warn_large = wx.CheckBox(pnl, -1, "") self.tc_hk_next = wx.TextCtrl(pnl, -1, size=(200, -1)) self.tc_hk_pause = wx.TextCtrl(pnl, -1, size=(200, -1)) self.tc_setcmd = wx.TextCtrl(pnl, -1, size=(200, -1)) self.sizer_grid_settings.AddMany( [ (st_logging, 0, wx.ALIGN_RIGHT), (self.cb_logging, 0, wx.ALIGN_LEFT), (st_usehotkeys, 0, wx.ALIGN_RIGHT), (self.cb_usehotkeys, 0, wx.ALIGN_LEFT), (st_warn_large, 0, wx.ALIGN_RIGHT), (self.cb_warn_large, 0, wx.ALIGN_LEFT), (st_hk_next, 0, wx.ALIGN_RIGHT), (self.tc_hk_next, 0, wx.ALIGN_LEFT), (st_hk_pause, 0, wx.ALIGN_RIGHT), (self.tc_hk_pause, 0, wx.ALIGN_LEFT), (st_setcmd, 0, wx.ALIGN_RIGHT), (self.tc_setcmd, 0, wx.ALIGN_LEFT), ] ) self.update_fields() self.button_save = wx.Button(self, label="Save") self.button_close = wx.Button(self, label="Close") self.button_save.Bind(wx.EVT_BUTTON, self.onSave) self.button_close.Bind(wx.EVT_BUTTON, self.onClose) self.sizer_buttons.AddStretchSpacer() self.sizer_buttons.Add(self.button_save, 0, wx.ALL, 5) self.sizer_buttons.Add(self.button_close, 0, wx.ALL, 5) self.sizer_main.Add(self.sizer_grid_settings, 0, wx.CENTER|wx.EXPAND|wx.ALL, 5) self.sizer_main.Add(self.sizer_buttons, 0, wx.EXPAND) self.SetSizer(self.sizer_main) self.sizer_main.Fit(parent)
Example #15
Source File: AboutDialog.py From OpenPLC_Editor with GNU General Public License v3.0 | 4 votes |
def __init__(self, parent, info): title = _("About") + " " + info.Name wx.Dialog.__init__(self, parent, title=title) self.info = info if parent and parent.GetIcon(): self.SetIcon(parent.GetIcon()) image = None if self.info.Icon: bitmap = wx.BitmapFromIcon(self.info.Icon) image = wx.StaticBitmap(self, bitmap=bitmap) name = wx.StaticText(self, label="%s %s" % (info.Name, info.Version)) description = wx.StaticText(self, label=info.Description) description.Wrap(400) copyright = wx.StaticText(self, label=info.Copyright) url = HyperLinkCtrl(self, label=info.WebSite[0], URL=info.WebSite[1]) font = name.GetClassDefaultAttributes().font font.SetWeight(wx.FONTWEIGHT_BOLD) font.SetPointSize(18) name.SetFont(font) credits = wx.Button(self, id=wx.ID_ABOUT, label=_("C&redits")) license = wx.Button(self, label=_("&License")) close = wx.Button(self, id=wx.ID_CANCEL, label=_("&Close")) btnSizer = wx.BoxSizer(wx.HORIZONTAL) btnSizer.Add(credits, flag=wx.CENTER | wx.LEFT | wx.RIGHT, border=5) btnSizer.Add(license, flag=wx.CENTER | wx.RIGHT, border=5) btnSizer.Add(close, flag=wx.CENTER | wx.RIGHT, border=5) sizer = wx.BoxSizer(wx.VERTICAL) if image: sizer.Add(image, flag=wx.CENTER | wx.TOP | wx.BOTTOM, border=5) sizer.Add(name, flag=wx.CENTER | wx.BOTTOM, border=10) sizer.Add(description, flag=wx.CENTER | wx.BOTTOM, border=10) sizer.Add(copyright, flag=wx.CENTER | wx.BOTTOM, border=10) sizer.Add(url, flag=wx.CENTER | wx.BOTTOM, border=15) sizer.Add(btnSizer, flag=wx.CENTER | wx.BOTTOM, border=5) container = wx.BoxSizer(wx.VERTICAL) container.Add(sizer, flag=wx.ALL, border=10) self.SetSizer(container) self.Layout() self.Fit() self.Centre() self.Show(True) self.SetEscapeId(close.GetId()) credits.Bind(wx.EVT_BUTTON, self.on_credits) license.Bind(wx.EVT_BUTTON, self.on_license) close.Bind(wx.EVT_BUTTON, lambda evt: self.Destroy())