Python wx.Platform() Examples
The following are 30
code examples of wx.Platform().
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: tree.py From wxGlade with MIT License | 6 votes |
def _set_cur_widget(self, editor): # set self.cur_widget; adjust label colors and bold if required (on Windows) if self.cur_widget and wx.Platform == "__WXMSW__" and self.cur_widget.item: item = self.cur_widget.item self.SetItemTextColour(item, wx.NullColour) self.SetItemBold( item, False ) self.cur_widget = editor item = editor.item self.EnsureVisible(item) # ensure that the icon is visible text_rect = self.GetBoundingRect(item, True) if text_rect.x<22: self.SetScrollPos(wx.HORIZONTAL, self.GetScrollPos(wx.HORIZONTAL) - 22 + text_rect.x) if wx.Platform == "__WXMSW__": self.SetItemBold(item, True) self.SetItemTextColour(item, wx.BLUE) s = editor._get_tooltip_string() common.main.user_message( s and s.replace("\n", " ") or "" )
Example #2
Source File: Viewer.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def OnScrollWindow(self, event): if self.Editor.HasCapture() and self.StartMousePos is not None: return if wx.Platform == '__WXMSW__': wx.CallAfter(self.RefreshVisibleElements) self.Editor.Freeze() wx.CallAfter(self.Editor.Thaw) elif event.GetOrientation() == wx.HORIZONTAL: self.RefreshVisibleElements(xp=event.GetPosition()) else: self.RefreshVisibleElements(yp=event.GetPosition()) # Handle scroll in debug to fully redraw area and ensuring # instance path is fully draw without flickering if self.Debug and wx.Platform != '__WXMSW__': x, y = self.GetViewStart() if event.GetOrientation() == wx.HORIZONTAL: self.Scroll(event.GetPosition(), y) else: self.Scroll(x, event.GetPosition()) else: event.Skip()
Example #3
Source File: BrowseLocationsDialog.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def GenerateLocationsTreeBranch(self, root, locations): to_delete = [] item, root_cookie = self.LocationsTree.GetFirstChild(root) for loc_infos in locations: infos = loc_infos.copy() if infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP] or\ infos["type"] in self.DirFilter and self.FilterType(infos["IEC_type"], infos["size"]): children = [child for child in infos.pop("children")] if not item.IsOk(): item = self.LocationsTree.AppendItem(root, infos["name"]) if wx.Platform != '__WXMSW__': item, root_cookie = self.LocationsTree.GetNextChild(root, root_cookie) else: self.LocationsTree.SetItemText(item, infos["name"]) self.LocationsTree.SetPyData(item, infos) self.LocationsTree.SetItemImage(item, self.TreeImageDict[infos["type"]]) self.GenerateLocationsTreeBranch(item, children) item, root_cookie = self.LocationsTree.GetNextChild(root, root_cookie) while item.IsOk(): to_delete.append(item) item, root_cookie = self.LocationsTree.GetNextChild(root, root_cookie) for item in to_delete: self.LocationsTree.Delete(item)
Example #4
Source File: FileManagementPanel.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent, controler, name, folder, enable_dragndrop=False): self.Folder = os.path.realpath(folder) self.EnableDragNDrop = enable_dragndrop if wx.Platform == '__WXMSW__': self.HomeDirectory = "/" else: self.HomeDirectory = os.path.expanduser("~") EditorPanel.__init__(self, parent, name, None, None) self.Controler = controler self.EditableFileExtensions = [] self.EditButton.Hide() self.SetIcon(GetBitmap("FOLDER"))
Example #5
Source File: backend_wx.py From matplotlib-4-abaqus with MIT License | 6 votes |
def set_linestyle(self, ls): """ Set the line style to be one of """ DEBUG_MSG("set_linestyle()", 1, self) self.select() GraphicsContextBase.set_linestyle(self, ls) try: self._style = GraphicsContextWx._dashd_wx[ls] except KeyError: self._style = wx.LONG_DASH# Style not used elsewhere... # On MS Windows platform, only line width of 1 allowed for dash lines if wx.Platform == '__WXMSW__': self.set_linewidth(1) self._pen.SetStyle(self._style) self.gfx_ctx.SetPen(self._pen) self.unselect()
Example #6
Source File: docpdf.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def open_pdf(pdffile, pagenum=None): if wx.Platform == '__WXMSW__': try: readerpath = get_acroversion() except Exception: wx.MessageBox("Acrobat Reader is not found or installed !") return None readerexepath = os.path.join(readerpath, "AcroRd32.exe") if os.path.isfile(readerexepath): open_win_pdf(readerexepath, pdffile, pagenum) else: return None else: readerexepath = os.path.join("/usr/bin", "xpdf") if os.path.isfile(readerexepath): open_lin_pdf(readerexepath, pdffile, pagenum) else: wx.MessageBox("xpdf is not found or installed !") return None
Example #7
Source File: backend_wx.py From neural-network-animation with MIT License | 6 votes |
def set_linestyle(self, ls): """ Set the line style to be one of """ DEBUG_MSG("set_linestyle()", 1, self) self.select() GraphicsContextBase.set_linestyle(self, ls) try: self._style = GraphicsContextWx._dashd_wx[ls] except KeyError: self._style = wx.LONG_DASH# Style not used elsewhere... # On MS Windows platform, only line width of 1 allowed for dash lines if wx.Platform == '__WXMSW__': self.set_linewidth(1) self._pen.SetStyle(self._style) self.gfx_ctx.SetPen(self._pen) self.unselect()
Example #8
Source File: backend_wx.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def gui_repaint(self, drawDC=None, origin='WX'): """ Performs update of the displayed image on the GUI canvas, using the supplied wx.PaintDC device context. The 'WXAgg' backend sets origin accordingly. """ DEBUG_MSG("gui_repaint()", 1, self) if self.IsShownOnScreen(): if not drawDC: # not called from OnPaint use a ClientDC drawDC = wx.ClientDC(self) # following is for 'WX' backend on Windows # the bitmap can not be in use by another DC, # see GraphicsContextWx._cache if wx.Platform == '__WXMSW__' and origin == 'WX': img = self.bitmap.ConvertToImage() bmp = img.ConvertToBitmap() drawDC.DrawBitmap(bmp, 0, 0) else: drawDC.DrawBitmap(self.bitmap, 0, 0)
Example #9
Source File: TextCtrlAutoComplete.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def SetChoices(self, choices): max_text_width = 0 max_text_height = 0 self.ListBox.Clear() for choice in choices: self.ListBox.Append(choice) w, h = self.ListBox.GetTextExtent(choice) max_text_width = max(max_text_width, w) max_text_height = max(max_text_height, h) itemcount = min(len(choices), MAX_ITEM_SHOWN) width = self.Parent.GetSize()[0] height = \ max_text_height * itemcount + \ LISTBOX_INTERVAL_HEIGHT * max(0, itemcount - 1) + \ 2 * LISTBOX_BORDER_HEIGHT if max_text_width + 10 > width: height += 15 size = wx.Size(width, height) if wx.Platform == '__WXMSW__': size.width -= 2 self.ListBox.SetSize(size) self.SetClientSize(size)
Example #10
Source File: TextCtrlAutoComplete.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def PopupListBox(self): if self.listbox is None: self.listbox = PopupWithListbox(self) # Show the popup right below or above the button # depending on available screen space... pos = self.ClientToScreen((0, 0)) sz = self.GetSize() if wx.Platform == '__WXMSW__': pos.x -= 2 pos.y -= 2 self.listbox.Position(pos, (0, sz[1])) self.RefreshListBoxChoices() self.listbox.Show()
Example #11
Source File: backend_wx.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def gui_repaint(self, drawDC=None, origin='WX'): """ Performs update of the displayed image on the GUI canvas, using the supplied wx.PaintDC device context. The 'WXAgg' backend sets origin accordingly. """ DEBUG_MSG("gui_repaint()", 1, self) if self.IsShownOnScreen(): if not drawDC: # not called from OnPaint use a ClientDC drawDC = wx.ClientDC(self) # following is for 'WX' backend on Windows # the bitmap can not be in use by another DC, # see GraphicsContextWx._cache if wx.Platform == '__WXMSW__' and origin == 'WX': img = self.bitmap.ConvertToImage() bmp = img.ConvertToBitmap() drawDC.DrawBitmap(bmp, 0, 0) else: drawDC.DrawBitmap(self.bitmap, 0, 0)
Example #12
Source File: backend_wx.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def gui_repaint(self, drawDC=None, origin='WX'): """ Performs update of the displayed image on the GUI canvas, using the supplied wx.PaintDC device context. The 'WXAgg' backend sets origin accordingly. """ DEBUG_MSG("gui_repaint()", 1, self) if self.IsShownOnScreen(): if not drawDC: # not called from OnPaint use a ClientDC drawDC = wx.ClientDC(self) # following is for 'WX' backend on Windows # the bitmap can not be in use by another DC, # see GraphicsContextWx._cache if wx.Platform == '__WXMSW__' and origin == 'WX': img = self.bitmap.ConvertToImage() bmp = img.ConvertToBitmap() drawDC.DrawBitmap(bmp, 0, 0) else: drawDC.DrawBitmap(self.bitmap, 0, 0)
Example #13
Source File: backend_wx.py From coffeegrindsize with MIT License | 6 votes |
def gui_repaint(self, drawDC=None, origin='WX'): """ Performs update of the displayed image on the GUI canvas, using the supplied wx.PaintDC device context. The 'WXAgg' backend sets origin accordingly. """ DEBUG_MSG("gui_repaint()", 1, self) if self.IsShownOnScreen(): if not drawDC: # not called from OnPaint use a ClientDC drawDC = wx.ClientDC(self) # following is for 'WX' backend on Windows # the bitmap can not be in use by another DC, # see GraphicsContextWx._cache if wx.Platform == '__WXMSW__' and origin == 'WX': img = self.bitmap.ConvertToImage() bmp = img.ConvertToBitmap() drawDC.DrawBitmap(bmp, 0, 0) else: drawDC.DrawBitmap(self.bitmap, 0, 0)
Example #14
Source File: backend_wx.py From ImageFusion with MIT License | 6 votes |
def set_linestyle(self, ls): """ Set the line style to be one of """ DEBUG_MSG("set_linestyle()", 1, self) self.select() GraphicsContextBase.set_linestyle(self, ls) try: self._style = GraphicsContextWx._dashd_wx[ls] except KeyError: self._style = wx.LONG_DASH# Style not used elsewhere... # On MS Windows platform, only line width of 1 allowed for dash lines if wx.Platform == '__WXMSW__': self.set_linewidth(1) self._pen.SetStyle(self._style) self.gfx_ctx.SetPen(self._pen) self.unselect()
Example #15
Source File: objdictedit.py From CANFestivino with GNU Lesser General Public License v2.1 | 6 votes |
def OnHelpCANFestivalMenu(self, event): #self.OpenHtmlFrame("CAN Festival Reference", os.path.join(ScriptDirectory, "doc/canfestival.html"), wx.Size(1000, 600)) if wx.Platform == '__WXMSW__': readerpath = get_acroversion() readerexepath = os.path.join(readerpath,"AcroRd32.exe") if(os.path.isfile(readerexepath)): os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", '"%s"'%os.path.join(ScriptDirectory, "doc","manual_en.pdf")) else: message = wx.MessageDialog(self, _("Check if Acrobat Reader is correctly installed on your computer"), _("ERROR"), wx.OK|wx.ICON_ERROR) message.ShowModal() message.Destroy() else: try: os.system("xpdf -remote CANFESTIVAL %s %d &"%(os.path.join(ScriptDirectory, "doc/manual_en.pdf"),16)) except: message = wx.MessageDialog(self, _("Check if xpdf is correctly installed on your computer"), _("ERROR"), wx.OK|wx.ICON_ERROR) message.ShowModal() message.Destroy()
Example #16
Source File: menubar.py From wxGlade with MIT License | 6 votes |
def create_widget(self): if self.IS_TOPLEVEL: # "top-level" menubar self.widget = wx.Frame(None, -1, misc.design_title(self.name)) self.widget.SetClientSize((400, 30)) self._mb = wx.MenuBar() self.widget.SetMenuBar(self._mb) self.widget.SetBackgroundColour(self._mb.GetBackgroundColour()) import os icon = compat.wx_EmptyIcon() xpm = os.path.join(config.icons_path, 'menubar.xpm') icon.CopyFromBitmap(misc.get_xpm_bitmap(xpm)) self.widget.SetIcon(icon) self.widget.Bind(wx.EVT_CLOSE, lambda e: self.hide_widget()) else: if wx.Platform=="_WXMAC__": return # XXX check how a toplevel menu bar behaves on Mac OS self.widget = self._mb = wx.MenuBar() if self.parent.widget: self.parent.widget.SetMenuBar(self.widget) if wx.Platform == '__WXMSW__' or wx.Platform == '__WXMAC__': self.widget.SetFocus = lambda : None self.widget.Bind(wx.EVT_LEFT_DOWN, self.on_set_focus) self.set_menus() # show the menus
Example #17
Source File: panel.py From wxGlade with MIT License | 6 votes |
def create_widget(self): if self.widget: # re-creating -> use old frame win = self.widget.GetTopLevelParent() else: style = wx.DEFAULT_FRAME_STYLE if common.pin_design_window: style |= wx.STAY_ON_TOP win = wx.Frame( common.main, -1, misc.design_title(self.name), size=(400, 300), style=style ) import os, compat icon = compat.wx_EmptyIcon() xpm = os.path.join(config.icons_path, 'panel.xpm') icon.CopyFromBitmap(misc.get_xpm_bitmap(xpm)) win.SetIcon(icon) win.Bind(wx.EVT_CLOSE, self.hide_widget) # CLOSE event of the frame, not the panel if wx.Platform == '__WXMSW__': win.CentreOnScreen() if self.scrollable: self.widget = wx.ScrolledWindow(win, self.id, style=0) else: self.widget = wx.Panel(win, self.id, style=0) self.widget.Bind(wx.EVT_ENTER_WINDOW, self.on_enter) self.widget.GetBestSize = self.get_widget_best_size #self.widget.SetSize = win.SetSize
Example #18
Source File: notebook.py From admin4 with Apache License 2.0 | 6 votes |
def DoInsertPage(self, page, pos): if not isinstance(page, wx.Window): page=page(self) ctl=page.GetControl() if pos == None: self.AddPage(ctl, page.name) self.pages.append(page) else: self.InsertPage(pos, ctl, page.name) self.pages.insert(pos, page) if isinstance(ctl, wx.ListCtrl): ctl.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemDoubleClick) ctl.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnItemRightClick) ctl.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick) if wx.Platform == "__WXMSW__": ctl.Bind(wx.EVT_RIGHT_UP, self.OnItemRightClick)
Example #19
Source File: edit_windows.py From wxGlade with MIT License | 6 votes |
def finish_widget_creation(self, level): WindowBase.finish_widget_creation(self, level) if self.CHILDREN: # not for MenuBar, ToolBar self.drop_target = clipboard.DropTarget(self) self.widget.SetDropTarget(self.drop_target) self.widget.SetMinSize = self.widget.SetSize if self.has_title: self.widget.SetTitle( misc.design_title(self.title) ) elif hasattr(self.widget, 'SetTitle'): self.widget.SetTitle(misc.design_title(self.name)) self.widget.Bind(wx.EVT_LEFT_DOWN, self.drop_sizer) self.widget.Bind(wx.EVT_ENTER_WINDOW, self.on_enter) self.widget.Bind(wx.EVT_CLOSE, self.hide_widget) if wx.Platform == '__WXMSW__': # MSW isn't smart enough to avoid overlapping windows, so at least move it away from the 3 wxGlade frames self.widget.Center()
Example #20
Source File: backend_wx.py From CogAlg with MIT License | 6 votes |
def gui_repaint(self, drawDC=None, origin='WX'): """ Performs update of the displayed image on the GUI canvas, using the supplied wx.PaintDC device context. The 'WXAgg' backend sets origin accordingly. """ DEBUG_MSG("gui_repaint()", 1, self) if self.IsShownOnScreen(): if not drawDC: # not called from OnPaint use a ClientDC drawDC = wx.ClientDC(self) # following is for 'WX' backend on Windows # the bitmap can not be in use by another DC, # see GraphicsContextWx._cache if wx.Platform == '__WXMSW__' and origin == 'WX': img = self.bitmap.ConvertToImage() bmp = img.ConvertToBitmap() drawDC.DrawBitmap(bmp, 0, 0) else: drawDC.DrawBitmap(self.bitmap, 0, 0)
Example #21
Source File: backend_wx.py From Computable with MIT License | 6 votes |
def set_linestyle(self, ls): """ Set the line style to be one of """ DEBUG_MSG("set_linestyle()", 1, self) self.select() GraphicsContextBase.set_linestyle(self, ls) try: self._style = GraphicsContextWx._dashd_wx[ls] except KeyError: self._style = wx.LONG_DASH# Style not used elsewhere... # On MS Windows platform, only line width of 1 allowed for dash lines if wx.Platform == '__WXMSW__': self.set_linewidth(1) self._pen.SetStyle(self._style) self.gfx_ctx.SetPen(self._pen) self.unselect()
Example #22
Source File: main.py From wxGlade with MIT License | 6 votes |
def pin_design_window(self): common.pin_design_window = not common.pin_design_window if common.pin_design_window != self._t_pin_design_window.IsToggled(): self._t_pin_design_window.Toggle() self.toolbar.Realize() self._m_pin_design_window.Check(common.pin_design_window) toplevel = self._get_toplevel() if not toplevel or not toplevel.widget: return frame = toplevel.widget.GetTopLevelParent() if not isinstance(frame, wx.Frame): return style = frame.GetWindowStyle() if common.pin_design_window: frame.SetWindowStyle( style | wx.STAY_ON_TOP) elif style & wx.STAY_ON_TOP: frame.ToggleWindowStyle(wx.STAY_ON_TOP) if wx.Platform=='__WXMSW__': frame.Iconize(True) frame.Iconize(False) else: toplevel.widget.Raise()
Example #23
Source File: testsupport_new.py From wxGlade with MIT License | 5 votes |
def _compare_files(self, expected_filename, generated_filename, check_mtime=False): self.assertTrue( os.path.isfile(generated_filename), "File %s was not generated"%generated_filename ) if check_mtime: self.assertGreater( os.stat(generated_filename).st_mtime, os.stat(expected_filename).st_mtime, "File was not overwritten" ) # open files, split into lines and convert to str/unicode expected = self._read_file_lines(expected_filename) generated = self._read_file_lines(generated_filename) if expected and expected[0].startswith(b'#!/usr/bin/env python'): expected[0] = expected[0].rstrip(b"3") if generated and generated[0].startswith(b'#!/usr/bin/env python'): generated[0] = generated[0].rstrip(b"3") if expected == generated: return False expected = [s.decode('ascii', 'replace') for s in expected] generated = [s.decode('ascii', 'replace') for s in generated] if wx.Platform == '__WXGTK__': # on gtk, the frames get resized after creation if len(expected)==len(generated): expected_ = [l for l in expected if not l.strip().startswith("<size>") and not "SetSize" in l] generated_ = [l for l in generated if not l.strip().startswith("<size>") and not "SetSize" in l] if expected_ == generated_: return False diff = difflib.unified_diff(expected, generated, fromfile=expected_filename, tofile=generated_filename, lineterm='') diff = list(diff) print( '\n'.join(diff[:40]) ) if len(diff)>40: print("...") #if compat.PYTHON3: self.assertFalse( diff, "Generated file and expected result differs:\n%s" % "\n".join(diff) ) return True
Example #24
Source File: DebugVariablePanel.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def RefreshHighlight(self, x_mouse, y_mouse): for idx, panel in enumerate(self.GraphicPanels): x, y = panel.GetPosition() width, height = panel.GetSize() rect = wx.Rect(x, y, width, height) if rect.InsideXY(x_mouse, y_mouse) or \ idx == 0 and y_mouse < 0 or \ idx == len(self.GraphicPanels) - 1 and y_mouse > panel.GetPosition()[1]: panel.RefreshHighlight(x_mouse - x, y_mouse - y) else: panel.SetHighlight(HIGHLIGHT_NONE) if wx.Platform == "__WXMSW__": self.RefreshView() else: self.ForceRefresh()
Example #25
Source File: wxglade.py From wxGlade with MIT License | 5 votes |
def init_stage2(use_gui): """Initialise the remaining (non-path) parts of wxGlade (second stage) use_gui: Starting wxGlade GUI""" config.use_gui = use_gui if use_gui: # import proper wx-module using wxversion, which is only available in Classic if compat.IS_CLASSIC: if not hasattr(sys, "frozen") and 'wx' not in sys.modules: try: import wxversion wxversion.ensureMinimal('2.8') except ImportError: msg = _('Please install missing Python module "wxversion".') logging.error(msg) sys.exit(msg) try: import wx except ImportError: msg = _('Please install missing Python module "wxPython".') logging.error(msg) sys.exit(msg) # store current version and platform ('not_set' is default) config.platform = wx.Platform config.wx_version = wx.__version__ if sys.platform=="win32": # register ".wxg" extension try: import msw msw.register_extensions(["wxg"], "wxGlade") except ImportError: pass # codewrites, widgets and sizers are loaded in class main.wxGladeFrame else: # use_gui has to be set before importing config common.init_preferences() common.init_codegen()
Example #26
Source File: tree.py From wxGlade with MIT License | 5 votes |
def show_toplevel(self, event, editor=None): "Event handler for left double-clicks: if the click is above a toplevel widget and this is hidden, shows it" if editor is None: try: x, y = event.GetPosition() except AttributeError: # if we are here, event is a CommandEvent and not a MouseEvent editor = self._GetItemData(self.GetSelection()) self.ExpandAllChildren(editor.item) # if we are here, the widget must be shown else: editor = self.find_editor_by_pos(x, y, toplevels_only=True) if editor is None or editor.IS_ROOT: return # the actual toplevel widget may be one level higher, e.g. for a Panel, which is embedded in a Frame set_size = None if editor.IS_TOPLEVEL: # toplevel window or a menu/status bar toplevel_widget = editor.widget if editor.check_prop("size") and editor.check_prop("toolbar") and editor.toolbar: # apply workaround for size changes due to a toolbar; this would cause problems with automatic testing set_size = editor.properties.get("size").get_size() else: toplevel_widget = editor.widget.GetParent() if not editor.is_visible(): # added by rlawson to expand node on showing top level widget self.ExpandAllChildren(editor.item) editor.show_widget() if wx.Platform != '__WXMSW__' and set_size is not None: # XXX integrate with above or remove above again? toplevel_widget = editor.widget # above it was not yet created wx.CallAfter(toplevel_widget.SetSize, set_size) else: editor.hide_widget() #toplevel_widget.GetTopLevelParent().Hide() if event: event.Skip() if "design" in editor.properties: editor.design.update_label()
Example #27
Source File: dialog.py From wxGlade with MIT License | 5 votes |
def builder(parent, index): "factory function for EditDialog objects" import window_dialog, edit_base, clipboard, panel base_classes = ['wxDialog', 'wxPanel'] klass = 'wxDialog' if common.root.language.lower()=='xrc' else 'MyDialog' dialog = window_dialog.WindowDialog(klass, base_classes, 'Select widget type', True) res = dialog.show() dialog.Destroy() if res is None: return klass, base = res name = 'dialog' if base == "wxDialog" else "panel" name = dialog.get_next_name(name) if base == "wxDialog": is_panel = False editor = EditDialog(name, parent, klass, name, "wxDEFAULT_DIALOG_STYLE") else: is_panel = True editor = panel.EditTopLevelPanel(name, parent, klass) edit_base.Slot(editor, 0) editor.create() if base == "wxDialog": editor.widget.Show() else: editor.widget.GetParent().Show() # the panel is created as child of a Frame editor.design.update_label() if wx.Platform == '__WXMSW__': if not is_panel: w = editor.widget else: w = editor.widget.GetParent() w.CenterOnScreen() w.Raise() editor.drop_target = clipboard.DropTarget(editor) editor.widget.SetDropTarget(editor.drop_target) return editor
Example #28
Source File: backend_wx.py From Computable with MIT License | 5 votes |
def get_wx_font(self, s, prop): """ Return a wx font. Cache instances in a font dictionary for efficiency """ DEBUG_MSG("get_wx_font()", 1, self) key = hash(prop) fontprop = prop fontname = fontprop.get_name() font = self.fontd.get(key) if font is not None: return font # Allow use of platform independent and dependent font names wxFontname = self.fontnames.get(fontname, wx.ROMAN) wxFacename = '' # Empty => wxPython chooses based on wx_fontname # Font colour is determined by the active wx.Pen # TODO: It may be wise to cache font information size = self.points_to_pixels(fontprop.get_size_in_points()) font =wx.Font(int(size+0.5), # Size wxFontname, # 'Generic' name self.fontangles[fontprop.get_style()], # Angle self.fontweights[fontprop.get_weight()], # Weight False, # Underline wxFacename) # Platform font name # cache the font and gc and return it self.fontd[key] = font return font
Example #29
Source File: DebugVariablePanel.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def ResetHighlight(self): for panel in self.GraphicPanels: panel.SetHighlight(HIGHLIGHT_NONE) if wx.Platform == "__WXMSW__": self.RefreshView() else: self.ForceRefresh()
Example #30
Source File: misc.py From wxGlade with MIT License | 5 votes |
def append_menu_item(menu, id, text, xpm_file_or_artid=None, **kwargs): # XXX change: move id to the end of the argument list? if compat.IS_CLASSIC and "helpString" in kwargs: kwargs["help"] = kwargs["helpString"] del kwargs["helpString"] item = wx.MenuItem(menu, id, text, **kwargs) if xpm_file_or_artid is not None: path = 'msw/' if wx.Platform == '__WXMSW__' else 'gtk/' path = os.path.join(config.icons_path, path) bmp = None if not isinstance(xpm_file_or_artid, bytes) or not xpm_file_or_artid.startswith(b'wxART_'): try: bmp = _item_bitmaps[xpm_file_or_artid] except KeyError: f = os.path.join(path, xpm_file_or_artid) if os.path.isfile(f): bmp = _item_bitmaps[xpm_file_or_artid] = wx.Bitmap(f, wx.BITMAP_TYPE_XPM) else: bmp = None else: # xpm_file_or_artid is an id for wx.ArtProvider bmp = wx.ArtProvider.GetBitmap( xpm_file_or_artid, wx.ART_MENU, (16, 16) ) if bmp is not None: try: item.SetBitmap(bmp) except AttributeError: pass if compat.IS_CLASSIC: menu.AppendItem(item) else: menu.Append(item) return item