def _CreateCanvas(self, parent): self._canvas = ogl.ShapeCanvas(parent) wx.EVT_LEFT_DOWN(self._canvas, self.OnLeftClick) wx.EVT_LEFT_UP(self._canvas, self.OnLeftUp) wx.EVT_MOTION(self._canvas, self.OnLeftDrag) wx.EVT_LEFT_DCLICK(self._canvas, self.OnLeftDoubleClick) wx.EVT_KEY_DOWN(self._canvas, self.OnKeyPressed) # need this otherwise mouse clicks don't set focus to this view wx.EVT_LEFT_DOWN(self._canvas, self.FocusOnClick) wx.EVT_LEFT_DCLICK(self._canvas, self.FocusOnClick) wx.EVT_RIGHT_DOWN(self._canvas, self.FocusOnClick) wx.EVT_RIGHT_DCLICK(self._canvas, self.FocusOnClick) wx.EVT_MIDDLE_DOWN(self._canvas, self.FocusOnClick) wx.EVT_MIDDLE_DCLICK(self._canvas, self.FocusOnClick) wx.EVT_KILL_FOCUS(self._canvas, self.OnKillFocus) wx.EVT_SET_FOCUS(self._canvas, self.OnFocus) self._canvas.SetScrollbars(20, 20, self._maxWidth / 20, self._maxHeight / 20) self._canvas.SetBackgroundColour(self._backgroundColor) self._diagram = ogl.Diagram() self._canvas.SetDiagram(self._diagram) self._diagram.SetCanvas(self._canvas) self._canvas.SetFont(NORMALFONT)
def __init__(self, parent, datasource, watermark=None): wx.ScrolledWindow.__init__(self, parent, id=wx.NewId(), style=wx.FULL_REPAINT_ON_RESIZE|wx.SUNKEN_BORDER) self.exceptioncount=0 self.EnableScrolling(False, False) self.datasource=datasource self._bufbmp=None self.active_section=None self._w, self._h=-1,-1 self.vheight, self.maxheight=self._h,self._h self.sections=[] self.sectionheights=[] self._scrollbarwidth=wx.SystemSettings_GetMetric(wx.SYS_VSCROLL_X) wx.EVT_SIZE(self, self.OnSize) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground) wx.EVT_LEFT_DOWN(self, self.OnLeftDown) wx.EVT_LEFT_DCLICK(self, self.OnLeftDClick) wx.EVT_RIGHT_DOWN(self, self.OnRightDown) if watermark is not None: wx.EVT_SCROLLWIN(self, self.OnScroll) bgcolour=wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW) if guihelper.IsMac(): bgcolour=wx.WHITE self.bgbrush=wx.TheBrushList.FindOrCreateBrush(bgcolour, wx.SOLID) if watermark: self.watermark=guihelper.getbitmap(watermark) else: self.watermark=None self.UpdateItems()
def __init__(self, parent, **traits): """ Creates a new widget. """ # Base class constructors. super(ImageWidget, self).__init__(**traits) # Add some padding around the image. size = (self.bitmap.GetWidth() + 10, self.bitmap.GetHeight() + 10) # Create the toolkit-specific control. self.control = wx.Window(parent, -1, size=size) self.control.__tag__ = 'hack' self._mouse_over = False self._button_down = False # Set up mouse event handlers: wx.EVT_ENTER_WINDOW(self.control, self._on_enter_window) wx.EVT_LEAVE_WINDOW(self.control, self._on_leave_window) wx.EVT_LEFT_DCLICK(self.control, self._on_left_dclick) wx.EVT_LEFT_DOWN(self.control, self._on_left_down) wx.EVT_LEFT_UP(self.control, self._on_left_up) wx.EVT_PAINT(self.control, self._on_paint) # Pens used to draw the 'selection' marker: # ZZZ: Make these class instances when moved to the wx toolkit code. self._selectedPenDark = wx.Pen( wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DSHADOW), 1, wx.SOLID) self._selectedPenLight = wx.Pen( wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DHIGHLIGHT), 1, wx.SOLID) return
def createWidgets(self): self.listCtrl = wxskinListCtrl(self, ID_LISTCTRL, style=wx.LC_REPORT | wx.SUNKEN_BORDER | wx.LC_SINGLE_SEL | wx.LC_VRULES | wx.LC_HRULES) self.listCtrl.InsertColumn(0, "Name") self.listCtrl.InsertColumn(1, "Number") ColumnSorterMixin.__init__(self, 2) self.currentItem = 0 wx.EVT_SIZE(self, self.OnSize) wx.EVT_LIST_ITEM_SELECTED(self, ID_LISTCTRL, self.OnItemSelected) wx.EVT_LIST_ITEM_ACTIVATED(self, ID_LISTCTRL, self.OnItemActivated) wx.EVT_CLOSE(self, self.closeWindow) wx.EVT_LEFT_DCLICK(self.listCtrl, self.OnPopupEdit) wx.EVT_RIGHT_DOWN(self.listCtrl, self.OnRightDown) # for wxMSW and wxGTK respectively wx.EVT_COMMAND_RIGHT_CLICK(self.listCtrl, ID_LISTCTRL, self.OnRightClick) wx.EVT_RIGHT_UP(self.listCtrl, self.OnRightClick)
def _on_close(self, event): # Might be scrollbars or other native components under # us that are generating this event if event.GetWindow() == self.control: self._gc = None wx.EVT_ERASE_BACKGROUND(self.control, None) wx.EVT_PAINT(self.control, None) wx.EVT_SIZE(self.control, None) wx.EVT_LEFT_DOWN(self.control, None) wx.EVT_LEFT_UP(self.control, None) wx.EVT_LEFT_DCLICK(self.control, None) wx.EVT_MIDDLE_DOWN(self.control, None) wx.EVT_MIDDLE_UP(self.control, None) wx.EVT_MIDDLE_DCLICK(self.control, None) wx.EVT_RIGHT_DOWN(self.control, None) wx.EVT_RIGHT_UP(self.control, None) wx.EVT_RIGHT_DCLICK(self.control, None) wx.EVT_MOTION(self.control, None) wx.EVT_ENTER_WINDOW(self.control, None) wx.EVT_LEAVE_WINDOW(self.control, None) wx.EVT_MOUSEWHEEL(self.control, None) wx.EVT_KEY_DOWN(self.control, None) wx.EVT_KEY_UP(self.control, None) wx.EVT_CHAR(self.control, None) wx.EVT_WINDOW_DESTROY(self.control, None) self.control.SetDropTarget(None) self.control = None self.component.cleanup(self) self.component.parent = None self.component.window = None self.component = None return
def __init__(self, parent, tasks, onSelect, onEdit, onCreate, popupMenu, **kwargs): self.__onDropURLCallback = kwargs.pop('onDropURL', None) self.__onDropFilesCallback = kwargs.pop('onDropFiles', None) self.__onDropMailCallback = kwargs.pop('onDropMail', None) self.__taskList = tasks self.__onSelect = onSelect self.__onEdit = onEdit self.__onCreate = onCreate self.__popupMenu = popupMenu self.__calFormat = self.CAL_WEEKLY self.__hdrFormat = self.HDR_DATE self.__drawNow = True self.__adapter = parent self.getItemTooltipData = parent.getItemTooltipData super(HierarchicalCalendar, self).__init__(parent, **kwargs) self.SetCalendarFormat( self.__calFormat ) # This calls _Invalidate() so no need to call SetHeaderFormat self.__tip = tooltip.SimpleToolTip(self) self.__dropTarget = draganddrop.DropTarget(self.OnDropURL, self.OnDropFiles, self.OnDropMail) self.SetDropTarget(self.__dropTarget) EVT_EVENT_SELECTION_CHANGED(self, self._OnSelectionChanged) EVT_EVENT_DATES_CHANGED(self, self._OnDatesChanged) wx.EVT_LEFT_DCLICK(self, self._OnLeftDClick) wx.EVT_RIGHT_UP(self, self._OnRightUp)
def __init__(self, parent, id=wx.ID_ANY, eventTarget=None): canvas.L5RCanvas.__init__(self, parent, id) self.eventTarget = eventTarget or self self.gameState = None self.player = None self.isLocal = False self.markerPos = None self.markerOffset = (0, 0) self.attachMarker = None self.texBorderFrame = self.LoadTexture( os.path.join(locationsettings.data_dir, "images/border2.png")) self.texAttach = self.LoadTexture( os.path.join(locationsettings.data_dir, "images/border3.png")) wx.EVT_LEFT_DOWN(self, self.OnLeftMouseDown) wx.EVT_LEFT_DCLICK(self, self.OnDoubleClick) wx.EVT_RIGHT_DOWN(self, self.OnRightMouseDown) wx.EVT_MOTION(self, self.OnMotion) wx.EVT_MOUSEWHEEL(self, self.OnMouseWheel) wx.EVT_MIDDLE_DOWN(self, self.OnMouseWheelDown) self.SetDropTarget( dragdrop.CardDropTarget(self.OnDragData, self.OnDragOver, self.OnDragLeave)) self.texToken = {} self.texMarker = {} self.contextCard = None self.hoverCard = None self.pfHeight = DEFAULT_PLAYFIELD_HEIGHT self.background = PlayfieldCanvasBackground()
def _init_ctrls(self, prnt): # generated method, don't edit wx.Frame.__init__(self, id=wxID_EDITORFRAME, name=u'EditorFrame', parent=prnt, pos=wx.Point(117, 109), size=wx.Size(437, 296), style=wx.DEFAULT_FRAME_STYLE, title=u'crontab.txt Editor') self._init_utils() self.SetClientSize(wx.Size(429, 269)) self.SetMenuBar(self.mainMenuBar) wx.EVT_CLOSE(self, self.OnEditorFrameClose) self.cronItemList = wx.ListCtrl(id=wxID_EDITORFRAMECRONITEMLIST, name=u'cronItemList', parent=self, pos=wx.Point(0, 0), size=wx.Size(429, 230), style=wx.LC_REPORT, validator=wx.DefaultValidator) self.cronItemList.SetToolTipString(u'double-click on an entry to edit') wx.EVT_LEFT_DCLICK(self.cronItemList, self.OnCronitemlistLeftDclick) wx.EVT_LIST_ITEM_SELECTED(self.cronItemList, wxID_EDITORFRAMECRONITEMLIST, self.OnCronitemlistListItemSelected) self.statusBar = wx.StatusBar(id=wxID_EDITORFRAMESTATUSBAR, name=u'statusBar', parent=self, style=0) self.statusBar.SetPosition(wx.Point(0, 230)) self.statusBar.SetSize(wx.Size(429, 20)) self._init_coll_statusBar_Fields(self.statusBar) self.SetStatusBar(self.statusBar)
def __init__(self, editor, parent, wid=-1, pos=wx.DefaultPosition, size=wx.DefaultSize): super(KeyBindingCtrl, self).__init__(parent, wid, pos, size, style=wx.CLIP_CHILDREN | wx.WANTS_CHARS) # Save the reference to the controlling editor object: self.editor = editor # Indicate we don't have the focus right now: editor.has_focus = False # Set up the 'erase background' event handler: wx.EVT_ERASE_BACKGROUND(self, self._on_erase_background) # Set up the 'paint' event handler: wx.EVT_PAINT(self, self._paint) # Set up the focus change handlers: wx.EVT_SET_FOCUS(self, self._get_focus) wx.EVT_KILL_FOCUS(self, self._lose_focus) # Set up mouse event handlers: wx.EVT_LEFT_DOWN(self, self._set_focus) wx.EVT_LEFT_DCLICK(self, self._clear_contents) # Handle key events: wx.EVT_CHAR(self, self._on_char)
def __init__(self, width, height, alpha = symbol, mirr = 0, parent = None): """ Initialise. width and height define the physical size of the CRT in cm. """ wx.Frame.__init__ (self, parent, -1, _("Snellen Chart")) # width/Y is screen size (X/Y in cm) #wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X) # screensizes = {_("14 inch"):(28, 21), _("16 inch"):(30, 23)} self.screen_width_cm = width self.screen_height_cm = height self.screen_width_pixel = 0 self.screen_height_pixel = 0 self.standard_patient_chart_distances = [3, 5, 6, 7.5, 9, 12, 15, 18, 24, 30, 48, 60] # in metres self.mirror = mirr self.alphabet = alpha wx.EVT_CLOSE (self, self.OnClose) wx.EVT_KEY_DOWN (self, self.OnKeyUp) wx.EVT_LEFT_UP (self, self.OnLeftDown) wx.EVT_RIGHT_UP (self, self.OnRightDown) wx.EVT_LEFT_DCLICK (self, self.OnDClick) wx.EVT_PAINT (self, self.OnPaint) # wx.EVT_WINDOW_CREATE (self, self.OnCreate) self.ShowFullScreen(1)
def __init__(self, parent): attribList = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24, glcanvas.WX_GL_STENCIL_SIZE, 8, 0) glcanvas.GLCanvas.__init__(self, parent, style=wx.WANTS_CHARS, attribList = attribList) self._base = self self._focus = None self._container = None self._container = glGuiContainer(self, (0,0)) self._shownError = False self._context = glcanvas.GLContext(self) self._glButtonsTexture = None self._glRobotTexture = None self._buttonSize = 64 self._animationList = [] self.glReleaseList = [] self._refreshQueued = False self._idleCalled = False wx.EVT_PAINT(self, self._OnGuiPaint) wx.EVT_SIZE(self, self._OnSize) wx.EVT_ERASE_BACKGROUND(self, self._OnEraseBackground) wx.EVT_LEFT_DOWN(self, self._OnGuiMouseDown) wx.EVT_LEFT_DCLICK(self, self._OnGuiMouseDown) wx.EVT_LEFT_UP(self, self._OnGuiMouseUp) wx.EVT_RIGHT_DOWN(self, self._OnGuiMouseDown) wx.EVT_RIGHT_DCLICK(self, self._OnGuiMouseDown) wx.EVT_RIGHT_UP(self, self._OnGuiMouseUp) wx.EVT_MIDDLE_DOWN(self, self._OnGuiMouseDown) wx.EVT_MIDDLE_DCLICK(self, self._OnGuiMouseDown) wx.EVT_MIDDLE_UP(self, self._OnGuiMouseUp) wx.EVT_MOTION(self, self._OnGuiMouseMotion) wx.EVT_CHAR(self, self._OnGuiKeyChar) wx.EVT_KILL_FOCUS(self, self.OnFocusLost) wx.EVT_IDLE(self, self._OnIdle)
def OnCreate(self, doc, flags): if len(doc.GetFilename()) == 0: wx.MessageBox(_("Cannot create a new image file.\n%s has no paint capability.") % wx.GetApp().GetAppName(), _("New Image File"), wx.OK | wx.ICON_EXCLAMATION) return False try: self._bitmap = wx.Image(doc.GetFilename()).ConvertToBitmap() except: wx.MessageBox(_("Error loading '%s'. %s") % (doc.GetPrintableName(), sys.exc_value), _("Open Image File"), wx.OK | wx.ICON_EXCLAMATION) return False frame = wx.GetApp().CreateDocumentFrame(self, doc, flags) panel = wx.Panel(frame, -1) self._ctrl = wx.StaticBitmap(panel, -1, self._bitmap, (0,0), (self._bitmap.GetWidth(), self._bitmap.GetHeight())) wx.EVT_LEFT_DOWN(self._ctrl, self.OnFocus) wx.EVT_LEFT_DCLICK(self._ctrl, self.OnFocus) wx.EVT_RIGHT_DOWN(self._ctrl, self.OnFocus) wx.EVT_RIGHT_DCLICK(self._ctrl, self.OnFocus) wx.EVT_MIDDLE_DOWN(self._ctrl, self.OnFocus) wx.EVT_MIDDLE_DCLICK(self._ctrl, self.OnFocus) panel.SetClientSize(self._bitmap.GetSize()) frame.SetClientSize(panel.GetSize()) self.Activate() return True
def editor_init(win): wx.EVT_UPDATE_UI(win, win.IDPM_CUT, win.OnUpdateUI) wx.EVT_UPDATE_UI(win, win.IDPM_COPY, win.OnUpdateUI) wx.EVT_UPDATE_UI(win, win.IDPM_PASTE, win.OnUpdateUI) wx.EVT_UPDATE_UI(win, win.IDPM_UNDO, win.OnUpdateUI) wx.EVT_UPDATE_UI(win, win.IDPM_REDO, win.OnUpdateUI) wx.EVT_LEFT_DCLICK(win, win.OnDClick)
def init_events(self): tID = self.GetId() wx.EVT_LIST_BEGIN_DRAG(self, tID, self.OnMouseDown) wx.EVT_LEFT_DCLICK(self, self.OnDoubleClick) wx.EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected) wx.EVT_LIST_ITEM_ACTIVATED(self, tID, self.OnItemSelected) wx.EVT_LIST_ITEM_RIGHT_CLICK(self, tID, self.OnRightClick) wx.EVT_CHAR(self, self.OnKeyPress)
def __register_interests(self): # events wx.EVT_LEFT_DCLICK(self._TCTRL_allergies, self._on_allergies_dclicked) # client internal signals gmDispatcher.connect(signal = u'post_patient_selection', receiver = self._on_post_patient_selection) gmDispatcher.connect(signal = u'focus_patient_search', receiver = self._on_focus_patient_search) gmDispatcher.connect(signal = u'gm_table_mod', receiver = self._on_database_signal)
def __init__(self, parent, mainframe): self.initmixin() wx.Panel.__init__(self, parent, -1) self.parent = parent self.mainframe = mainframe self.pref = mainframe.pref if not hasattr(self.pref, 'share_nodes'): self.pref.share_nodes = [] self.processors = {} # self.callplugin('add_process_class', self, self.processors) self.sizer = wx.BoxSizer(wx.VERTICAL) self.shareimagelist = imagelist = wx.ImageList(16, 16) #add share image list self.imagefiles = {} self.imageids = {} self.callplugin('add_images', self.imagefiles) for name, imagefile in self.imagefiles.items(): self.add_image(name, imagefile) self.tree = wx.TreeCtrl(self, -1, style = wx.TR_EDIT_LABELS|wx.TR_SINGLE|wx.TR_TWIST_BUTTONS|wx.TR_HAS_BUTTONS|wx.TR_ROW_LINES|wx.TR_HIDE_ROOT) self.tree.SetImageList(self.shareimagelist) self.sizer.Add(self.tree, 1, wx.EXPAND) self.root = self.tree.AddRoot('Share') self.nodes = {} self.ID = 1 self.read() wx.EVT_TREE_SEL_CHANGING(self.tree, self.tree.GetId(), self.OnChanging) wx.EVT_TREE_SEL_CHANGED(self.tree, self.tree.GetId(), self.OnChanged) wx.EVT_TREE_BEGIN_LABEL_EDIT(self.tree, self.tree.GetId(), self.OnBeginChangeLabel) wx.EVT_TREE_END_LABEL_EDIT(self.tree, self.tree.GetId(), self.OnChangeLabel) wx.EVT_TREE_ITEM_ACTIVATED(self.tree, self.tree.GetId(), self.OnSelected) wx.EVT_TREE_ITEM_RIGHT_CLICK(self.tree, self.tree.GetId(), self.OnRClick) wx.EVT_RIGHT_UP(self.tree, self.OnRClick) wx.EVT_TREE_DELETE_ITEM(self.tree, self.tree.GetId(), self.OnDeleteItem) wx.EVT_LEFT_DCLICK(self.tree, self.OnDoubleClick) wx.EVT_TREE_ITEM_EXPANDING(self.tree, self.tree.GetId(), self.OnExpanding) from modules import Id wx.EVT_UPDATE_UI(self, Id.makeid(self, 'IDPM_DEL'), self.OnUpdateUI) #add init process self.callplugin('init', self) self.SetSizer(self.sizer) self.SetAutoLayout(True) self.popmenus = None
def __init__(self, *args, **kwds): # begin wxGlade: WaveformView.__init__ kwds["style"] = wx.BORDER_SUNKEN | wx.TAB_TRAVERSAL wx.ScrolledWindow.__init__(self, *args, **kwds) self.__set_properties() self.__do_layout() # end wxGlade # test for wxPython type self.cdc = wx.ClientDC(self) self.isWxPhoenix = False if not "SetClippingRect" in dir( self.cdc ): # TODO: Test this version: if "SetClippingRect" not in dir(cdc) self.isWxPhoenix = True # Other initialization self.doc = None self.maxWidth = 1 self.maxHeight = 1 self.isDragging = False self.basicScrubbing = False self.curFrame = 0 self.oldFrame = 0 self.buffer = None self.clipRect = None self.sampleWidth = defaultSampleWidth self.samplesPerFrame = defaultSamplesPerFrame self.samplesPerSec = 24 * self.samplesPerFrame self.frameWidth = self.sampleWidth * self.samplesPerFrame self.phraseBottom = 16 self.wordBottom = 32 self.phonemeTop = 128 self.didresize = 0 # Connect event handlers # window events wx.EVT_PAINT(self, self.OnPaint) wx.EVT_SIZE(self, self.OnSize) wx.EVT_IDLE(self, self.OnIdle) # mouse events wx.EVT_LEFT_DOWN(self, self.OnMouseDown) wx.EVT_RIGHT_DOWN(self, self.OnMouseDown) wx.EVT_LEFT_DCLICK(self, self.OnMouseDown) wx.EVT_LEFT_UP(self, self.OnMouseUp) wx.EVT_RIGHT_UP(self, self.OnMouseUp) wx.EVT_MOTION(self, self.OnMouseMove) wx.EVT_MOUSEWHEEL(self, self.OnMouseWheel) # Force an update self.OnSize()
def __init__(self, parent, filename): # Use the WANTS_CHARS style so the panel doesn't eat the Return key. wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS) wx.EVT_SIZE(self, self.OnSize) tID = wx.NewId() self.tree = MyTreeCtrl( self, tID, wx.DefaultPosition, wx.DefaultSize, wx.TR_HAS_BUTTONS | wx.TR_EDIT_LABELS, #| wx.TR_MULTIPLE #| wx.TR_HIDE_ROOT ) isz = (16, 16) il = wx.ImageList(isz[0], isz[1]) # wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz) -> wx.ArtProvider.GetBitmap()/3 self.folderIdx = il.Add( wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz)) self.folderOpenIdx = il.Add( wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, isz)) self.fileIdx = il.Add( wx.ArtProvider.GetBitmap(wx.ART_REPORT_VIEW, wx.ART_OTHER, isz)) #self.fileIdx = self.il.Add(images.getFile1Bitmap()) #self.smileidx = self.il.Add(images.getSmilesBitmap()) self.tree.SetImageList(il) self.il = il # NOTE: 1 tree items have to have a data object in order to be sorted. # 2 Since our compare just uses the labels we don't need real data, so we'll just # use None below for the item data. wx.EVT_TREE_ITEM_EXPANDED(self, tID, self.OnItemExpanded) wx.EVT_TREE_ITEM_COLLAPSED(self, tID, self.OnItemCollapsed) wx.EVT_TREE_SEL_CHANGED(self, tID, self.OnSelChanged) wx.EVT_TREE_BEGIN_LABEL_EDIT(self, tID, self.OnBeginEdit) wx.EVT_TREE_END_LABEL_EDIT(self, tID, self.OnEndEdit) wx.EVT_TREE_ITEM_ACTIVATED(self, tID, self.OnActivate) wx.EVT_LEFT_DCLICK(self.tree, self.OnLeftDClick) wx.EVT_RIGHT_DOWN(self.tree, self.OnRightClick) wx.EVT_RIGHT_UP(self.tree, self.OnRightUp) #?? wx.EVT_COMMAND(self, 103,103, self.OnFileOpened) # Newer wxWidgets has no EVT_COMMAND # load default tree if filename != "": self.reload_tree(filename)
def __init__(self, parent, application): id = wx.NewId() style = wx.TR_DEFAULT_STYLE|wx.TR_HAS_VARIABLE_ROW_HEIGHT if wx.Platform == '__WXGTK__': style |= wx.TR_NO_LINES|wx.TR_FULL_ROW_HIGHLIGHT elif wx.Platform == '__WXMAC__': style &= ~wx.TR_ROW_LINES wx.TreeCtrl.__init__(self, parent, id, style=style) root_node = Tree.Node(application) self.cur_widget = None # reference to the selected widget Tree.__init__(self, root_node, application) image_list = wx.ImageList(21, 21) image_list.Add(wx.Bitmap(os.path.join(common.wxglade_path, 'icons/application.xpm'), wx.BITMAP_TYPE_XPM)) for w in WidgetTree.images: ## WidgetTree.images[w] = image_list.Add(wx.Bitmap( ## WidgetTree.images[w], wx.BITMAP_TYPE_XPM)) WidgetTree.images[w] = image_list.Add( misc.get_xpm_bitmap(WidgetTree.images[w])) self.AssignImageList(image_list) root_node.item = self.AddRoot(_('Application'), 0) self.SetPyData(root_node.item, root_node) self.skip_select = 0 # necessary to avoid an infinite loop on win32, as # SelectItem fires an EVT_TREE_SEL_CHANGED event self.title = ' ' self.set_title(self.title) self.auto_expand = True # this control the automatic expansion of # nodes: it is set to False during xml loading self._show_menu = misc.wxGladePopupMenu('widget') # popup menu to # show toplevel # widgets SHOW_ID = wx.NewId() self._show_menu.Append(SHOW_ID, _('Show')) wx.EVT_TREE_SEL_CHANGED(self, id, self.on_change_selection) wx.EVT_RIGHT_DOWN(self, self.popup_menu) wx.EVT_LEFT_DCLICK(self, self.show_toplevel) wx.EVT_MENU(self, SHOW_ID, self.show_toplevel) def on_key_down(event): evt_flags = 0 if event.ControlDown(): evt_flags = wx.ACCEL_CTRL evt_key = event.GetKeyCode() for flags, key, function in misc.accel_table: if evt_flags == flags and evt_key == key: wx.CallAfter(function) break event.Skip() wx.EVT_KEY_DOWN(self, on_key_down)
def __init__(self, parent, panel, side, style=0): self.initmixin() FNB.FlatNotebook.__init__(self, parent, -1, style=style | FNB.FNB_VC8 | FNB.FNB_X_ON_TAB | FNB.FNB_NO_X_BUTTON, size=(0, 0)) self.parent = parent self.panel = panel self.side = side self.mainframe = self.panel.mainframe #@add_menu menulist self.callplugin_once('add_menu', Notebook.popmenulist) #@add_menu_image_list imagelist self.callplugin_once('add_menu_image_list', Notebook.imagelist) #@add_page_image_list imagelist self.callplugin_once('add_page_image_list', Notebook.pageimagelist) self.popmenu = makemenu.makepopmenu(self, self.popmenulist, self.imagelist) self.SetRightClickMenu(self.popmenu) FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged) # wx.EVT_LEFT_UP(self, self.OnPageChanged) wx.EVT_LEFT_DCLICK(self._pages, self.OnDClick) # wx.EVT_RIGHT_DOWN(self, self.OnPopUp) FNB.EVT_FLATNOTEBOOK_PAGE_CLOSING(self, self.GetId(), self.OnClose) self.SetActiveTabColour('#7FFFD4') self.pageimageindex = {} pageimages = wx.ImageList(16, 16) for i, v in enumerate(self.pageimagelist.items()): name, imagefilename = v image = common.getpngimage(imagefilename) pageimages.Add(image) self.pageimageindex[name] = i self.pageimages = pageimages self.SetImageList(self.pageimages) self.delete_must = False self.old_size = None self.full = False self.callplugin('init', self)
def __init__(self, parent, index, rgb, **kwargs): if 'title' in kwargs: title = kwargs['title'] else: title = 'SPy Image' # wxFrame.__init__(self, parent, index, "SPy Frame") # wxScrolledWindow.__init__(self, parent, index, style = wxSUNKEN_BORDER) img = wx.EmptyImage(rgb.shape[0], rgb.shape[1]) img = wx.EmptyImage(rgb.shape[1], rgb.shape[0]) img.SetData(rgb.tostring()) self.bmp = img.ConvertToBitmap() self.kwargs = kwargs wx.Frame.__init__(self, parent, index, title, wx.DefaultPosition) self.SetClientSizeWH(self.bmp.GetWidth(), self.bmp.GetHeight()) wx.EVT_PAINT(self, self.on_paint) wx.EVT_LEFT_DCLICK(self, self.left_double_click)
def __init__(self, parent, id, getCfgGui): style = wx.FULL_REPAINT_ON_RESIZE wx.Window.__init__(self, parent, id, style=style) self.getCfgGui = getCfgGui # pages, i.e., [wx.Window, name] lists. note that 'name' must be an # Unicode string. self.pages = [] # index of selected page self.selected = -1 # index of first visible tab self.firstTab = 0 # how much padding to leave horizontally at the ends of the # control, and within each tab self.paddingX = 10 # starting Y-pos of text in labels self.textY = 5 # width of a single tab self.tabWidth = 150 # width, height, spacing, y-pos of arrows self.arrowWidth = 8 self.arrowHeight = 13 self.arrowSpacing = 3 self.arrowY = 5 # initialized in OnPaint since we don't know our height yet self.font = None self.boldFont = None self.SetMinSize(wx.Size( self.paddingX * 2 + self.arrowWidth * 2 + self.arrowSpacing +\ self.tabWidth + 5, TAB_BAR_HEIGHT)) wx.EVT_LEFT_DOWN(self, self.OnLeftDown) wx.EVT_LEFT_DCLICK(self, self.OnLeftDown) wx.EVT_SIZE(self, self.OnSize) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
def __init__(self, *args, **kwds): # begin wxGlade: WaveformView.__init__ kwds["style"] = wx.SUNKEN_BORDER | wx.TAB_TRAVERSAL wx.ScrolledWindow.__init__(self, *args, **kwds) self.__set_properties() self.__do_layout() # end wxGlade # Other initialization self.doc = None self.currentVoice = None self.maxWidth = 1 self.maxHeight = 1 self.isDragging = False self.basicScrubbing = False self.curFrame = 0 self.oldFrame = 0 self.buffer = None self.clipRect = None self.sampleWidth = defaultSampleWidth self.samplesPerFrame = defaultSamplesPerFrame self.samplesPerSec = 24 * self.samplesPerFrame self.frameWidth = self.sampleWidth * self.samplesPerFrame self.phraseBottom = 16 self.wordBottom = 32 self.phonemeTop = 128 self.voice = None # Connect event handlers # window events wx.EVT_PAINT(self, self.OnPaint) wx.EVT_SIZE(self, self.OnSize) # mouse events wx.EVT_LEFT_DOWN(self, self.OnMouseDown) wx.EVT_RIGHT_DOWN(self, self.OnMouseDown) wx.EVT_LEFT_DCLICK(self, self.OnMouseDown) wx.EVT_LEFT_UP(self, self.OnMouseUp) wx.EVT_RIGHT_UP(self, self.OnMouseUp) wx.EVT_MOTION(self, self.OnMouseMove) # Force an update self.OnSize()
def __init__(self, parent): attrib_list = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24, glcanvas.WX_GL_STENCIL_SIZE, 8, 0) glcanvas.GLCanvas.__init__(self, parent, style=wx.WANTS_CHARS, attribList=attrib_list) self._base = self self._focus = None self._container = None self._container = glGuiContainer(self, (0, 0)) self._shown_error = False self._context = glcanvas.GLContext(self) self._button_size = 64 self._animation_list = [] self.gl_release_list = [] self._refresh_queued = False self._idle_called = False wx.EVT_PAINT(self, self._on_gui_paint) wx.EVT_SIZE(self, self._on_size) wx.EVT_ERASE_BACKGROUND(self, self._on_erase_background) wx.EVT_LEFT_DOWN(self, self._on_gui_mouse_down) wx.EVT_LEFT_DCLICK(self, self._on_gui_mouse_down) wx.EVT_LEFT_UP(self, self._on_gui_mouse_up) wx.EVT_RIGHT_DOWN(self, self._on_gui_mouse_down) wx.EVT_RIGHT_DCLICK(self, self._on_gui_mouse_down) wx.EVT_RIGHT_UP(self, self._on_gui_mouse_up) wx.EVT_MIDDLE_DOWN(self, self._on_gui_mouse_down) wx.EVT_MIDDLE_DCLICK(self, self._on_gui_mouse_down) wx.EVT_MIDDLE_UP(self, self._on_gui_mouse_up) wx.EVT_MOTION(self, self._on_gui_mouse_motion) wx.EVT_KEY_DOWN(self, self._on_gui_key_down) wx.EVT_KEY_UP(self, self._on_gui_key_up) wx.EVT_KILL_FOCUS(self, self._on_focus_lost) wx.EVT_IDLE(self, self._on_idle)
def dispose(self): """ Disposes of the contents of an editor. """ # Remove all of the wx event handlers: control = self.control parent = control.GetParent() id = control.GetId() wx.EVT_LIST_BEGIN_DRAG(parent, id, None) wx.EVT_LIST_BEGIN_LABEL_EDIT(parent, id, None) wx.EVT_LIST_END_LABEL_EDIT(parent, id, None) wx.EVT_LIST_ITEM_SELECTED(parent, id, None) wx.EVT_LIST_ITEM_DESELECTED(parent, id, None) wx.EVT_LIST_KEY_DOWN(parent, id, None) wx.EVT_LIST_ITEM_ACTIVATED(parent, id, None) wx.EVT_LIST_COL_END_DRAG(parent, id, None) wx.EVT_LIST_COL_RIGHT_CLICK(parent, id, None) wx.EVT_LIST_COL_CLICK(parent, id, None) wx.EVT_LEFT_DOWN(control, None) wx.EVT_LEFT_DCLICK(control, None) wx.EVT_RIGHT_DOWN(control, None) wx.EVT_RIGHT_DCLICK(control, None) wx.EVT_MOTION(control, None) wx.EVT_SIZE(control, None) self.context_object.on_trait_change( self.update_editor, self.extended_name + '_items', remove=True) if self.factory.auto_update: self.context_object.on_trait_change( self.refresh_editor, self.extended_name + '.-', remove=True) self.on_trait_change(self._refresh, 'adapter.+update', remove=True) self.on_trait_change(self._rebuild_all, 'adapter.columns', remove=True) super(TabularEditor, self).dispose()
def __init__(self, parent, aFileName = None): wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS) # our actual list tID = wx.NewId() self.list = gmXdtListCtrl( self, tID, style=wx.LC_REPORT | wx.SUNKEN_BORDER | wx.LC_VRULES )#|wx.LC_HRULES) self.list.InsertColumn(0, _("XDT field")) self.list.InsertColumn(1, _("XDT field content")) self.filename = aFileName # set up events wx.EVT_SIZE(self, self.OnSize) wx.EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected) wx.EVT_LIST_ITEM_DESELECTED(self, tID, self.OnItemDeselected) wx.EVT_LIST_ITEM_ACTIVATED(self, tID, self.OnItemActivated) wx.EVT_LIST_DELETE_ITEM(self, tID, self.OnItemDelete) wx.EVT_LIST_COL_CLICK(self, tID, self.OnColClick) wx.EVT_LIST_COL_RIGHT_CLICK(self, tID, self.OnColRightClick) # wx.EVT_LIST_COL_BEGIN_DRAG(self, tID, self.OnColBeginDrag) # wx.EVT_LIST_COL_DRAGGING(self, tID, self.OnColDragging) # wx.EVT_LIST_COL_END_DRAG(self, tID, self.OnColEndDrag) wx.EVT_LEFT_DCLICK(self.list, self.OnDoubleClick) wx.EVT_RIGHT_DOWN(self.list, self.OnRightDown) if wx.Platform == '__WXMSW__': wx.EVT_COMMAND_RIGHT_CLICK(self.list, tID, self.OnRightClick) elif wx.Platform == '__WXGTK__': wx.EVT_RIGHT_UP(self.list, self.OnRightClick)
def __init__(self, parent, usernameList): wx.ScrolledWindow.__init__(self, parent) # load the map image and prepare a DC for it mapImageFile = os.path.normpath( os.path.join(MEDIAROOT, "images/map.jpg")) mapImage = wx.Image(mapImageFile, wx.BITMAP_TYPE_JPEG) self.mapBitmap = wx.BitmapFromImage(mapImage) self.bmpDC = wx.MemoryDC() mapImageFile = os.path.normpath( os.path.join(MEDIAROOT, "images/map-quarter.jpg")) mapImage = wx.Image(mapImageFile, wx.BITMAP_TYPE_JPEG) self.mapBitmapSmall = wx.BitmapFromImage(mapImage) self.bmpDC.SelectObject(self.mapBitmapSmall) self.zoomLevel = 2 self.pushpinOffset = (-8, 35) # configure scrollbars self.SetVirtualSize( (self.mapBitmapSmall.GetWidth(), self.mapBitmapSmall.GetHeight())) self.SetScrollRate(10, 10) self.maskColour = wx.Colour(10, 10, 10) self.pen = wx.Pen(wx.BLACK, 3, wx.SOLID) self.brush = wx.Brush(wx.WHITE, wx.SOLID) self.bgBrush = wx.Brush(self.maskColour, wx.SOLID) self.pushpinDC = wx.MemoryDC() self.labelsShown = False self.playerLoc = [] self.pushpins = [] self.pushpinBackgrounds = [] self.pushpinsDrawn = [] self.labels = [] for i in range(6): self.playerLoc.append(0) filename = os.path.normpath( os.path.join(MEDIAROOT, "images/pin" + str(i) + ".png")) pushpinImage = wx.Image(filename, wx.BITMAP_TYPE_ANY) pushpinImage.SetMaskColour( 255, 0, 242) # the purplish colour is not to be drawn pushpinBitmap = wx.BitmapFromImage(pushpinImage) self.pushpins.append(pushpinBitmap) pushpinBackBmp = wx.EmptyBitmap(pushpinBitmap.GetWidth(), pushpinBitmap.GetHeight(), -1) self.pushpinBackgrounds.append(pushpinBackBmp) self.labels.append( TextPanel(self, " " + usernameList[i][:20] + " ", 10, wx.SIMPLE_BORDER)) self.labels[i].Hide() self.labels[i].SetBackgroundColour(wx.Colour(220, 220, 220)) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground) # scroll the map on middle or right button drag wx.EVT_MIDDLE_DOWN(self, self.handleMiddleOrRightMouse) wx.EVT_RIGHT_DOWN(self, self.handleMiddleOrRightMouse) wx.EVT_MOTION(self, self.handleMoveMouse) wx.EVT_LEFT_DCLICK(self, self.propagateDClick)
def btnDblClick(btn, func): if misc.isUnix: wx.EVT_LEFT_DCLICK(btn, func)
def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ factory = self.factory # Set up the adapter to use: self.adapter = factory.adapter # Determine the style to use for the list control: style = wx.LC_REPORT | wx.LC_VIRTUAL | wx.BORDER_NONE if factory.editable_labels: style |= wx.LC_EDIT_LABELS if factory.horizontal_lines: style |= wx.LC_HRULES if factory.vertical_lines: style |= wx.LC_VRULES if not factory.multi_select: style |= wx.LC_SINGLE_SEL if not factory.show_titles: style |= wx.LC_NO_HEADER # Create the list control and link it back to us: self.control = control = wxListCtrl( parent, -1, style=style, can_edit=factory.editable, edit_labels=factory.editable_labels) control._editor = self # Create the list control column: #fixme: what do we do here? #control.InsertColumn( 0, '' ) # Set up the list control's event handlers: id = control.GetId() wx.EVT_LIST_BEGIN_DRAG(parent, id, self._begin_drag) wx.EVT_LIST_BEGIN_LABEL_EDIT(parent, id, self._begin_label_edit) wx.EVT_LIST_END_LABEL_EDIT(parent, id, self._end_label_edit) wx.EVT_LIST_ITEM_SELECTED(parent, id, self._item_selected) wx.EVT_LIST_ITEM_DESELECTED(parent, id, self._item_selected) wx.EVT_LIST_KEY_DOWN(parent, id, self._key_down) wx.EVT_LIST_ITEM_ACTIVATED(parent, id, self._item_activated) wx.EVT_LIST_COL_END_DRAG(parent, id, self._size_modified) wx.EVT_LIST_COL_RIGHT_CLICK(parent, id, self._column_right_clicked) wx.EVT_LIST_COL_CLICK(parent, id, self._column_clicked) wx.EVT_LEFT_DOWN(control, self._left_down) wx.EVT_LEFT_DCLICK(control, self._left_dclick) wx.EVT_RIGHT_DOWN(control, self._right_down) wx.EVT_RIGHT_DCLICK(control, self._right_dclick) wx.EVT_MOTION(control, self._motion) wx.EVT_SIZE(control, self._size_modified) # Set up the drag and drop target: if PythonDropTarget is not None: control.SetDropTarget(PythonDropTarget(self)) # Set up the selection listener (if necessary): if factory.multi_select: self.sync_value(factory.selected, 'multi_selected', 'both', is_list=True) self.sync_value(factory.selected_row, 'multi_selected_rows', 'both', is_list=True) else: self.sync_value(factory.selected, 'selected', 'both') self.sync_value(factory.selected_row, 'selected_row', 'both') # Synchronize other interesting traits as necessary: self.sync_value(factory.update, 'update', 'from') self.sync_value(factory.activated, 'activated', 'to') self.sync_value(factory.activated_row, 'activated_row', 'to') self.sync_value(factory.clicked, 'clicked', 'to') self.sync_value(factory.dclicked, 'dclicked', 'to') self.sync_value(factory.right_clicked, 'right_clicked', 'to') self.sync_value(factory.right_dclicked, 'right_dclicked', 'to') self.sync_value(factory.column_clicked, 'column_clicked', 'to') # Make sure we listen for 'items' changes as well as complete list # replacements: try: self.context_object.on_trait_change(self.update_editor, self.extended_name + '_items', dispatch='ui') except: pass # If the user has requested automatic update, attempt to set up the # appropriate listeners: if factory.auto_update: self.context_object.on_trait_change(self.refresh_editor, self.extended_name + '.-', dispatch='ui') # Create the mapping from user supplied images to wx.ImageList indices: for image_resource in factory.images: self._add_image(image_resource) # Refresh the editor whenever the adapter changes: self.on_trait_change(self._refresh, 'adapter.+update', dispatch='ui') # Rebuild the editor columns and headers whenever the adapter's # 'columns' changes: self.on_trait_change(self._rebuild_all, 'adapter.columns', dispatch='ui') # Make sure the tabular view gets initialized: self._rebuild() # Set the list control's tooltip: self.set_tooltip()
def __init__(self, parent, mainframe, dirs=None): self.initmixin() wx.Panel.__init__(self, parent, -1) self.parent = parent self.mainframe = mainframe self.pref = mainframe.pref self.sizer = wx.BoxSizer(wx.VERTICAL) imagelist = mainframe.dirbrowser_imagelist self.dirbrowserimagelist = wx.ImageList(16, 16) self.close_image = self.add_image( common.getpngimage(imagelist['close'])) self.open_image = self.add_image(common.getpngimage(imagelist['open'])) self.item_image = self.add_image(common.getpngimage(imagelist['item'])) self.deal_file_images() style = wx.TR_EDIT_LABELS | wx.TR_SINGLE | wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS | wx.TR_TWIST_BUTTONS if wx.Platform == '__WXMSW__': style = style | wx.TR_ROW_LINES elif wx.Platform == '__WXGTK__': style = style | wx.TR_NO_LINES self.tree = wx.TreeCtrl(self, -1, style=style) self.tree.SetImageList(self.dirbrowserimagelist) self.sizer.Add(self.tree, 1, wx.EXPAND) self.root = self.tree.AddRoot('DirBrowser') #add drop target self.SetDropTarget(MyFileDropTarget(self)) # wx.EVT_TREE_SEL_CHANGED(self.tree, self.tree.GetId(), self.OnChanged) wx.EVT_TREE_BEGIN_LABEL_EDIT(self.tree, self.tree.GetId(), self.OnBeginChangeLabel) wx.EVT_TREE_END_LABEL_EDIT(self.tree, self.tree.GetId(), self.OnChangeLabel) wx.EVT_TREE_ITEM_ACTIVATED(self.tree, self.tree.GetId(), self.OnSelected) # wx.EVT_TREE_ITEM_RIGHT_CLICK(self.tree, self.tree.GetId(), self.OnRClick) wx.EVT_RIGHT_UP(self.tree, self.OnRClick) wx.EVT_RIGHT_DOWN(self.tree, self.OnRightDown) wx.EVT_TREE_DELETE_ITEM(self.tree, self.tree.GetId(), self.OnDeleteItem) wx.EVT_LEFT_DCLICK(self.tree, self.OnDoubleClick) wx.EVT_TREE_ITEM_EXPANDING(self.tree, self.tree.GetId(), self.OnExpanding) wx.EVT_KEY_DOWN(self.tree, self.OnKeyDown) wx.EVT_CHAR(self.tree, self.OnChar) self.SetSizer(self.sizer) self.SetAutoLayout(True) self.nodes = {} self.ID = 1 self.cache = None #@add_project self.callplugin_once('add_project', DirBrowser.project_names) pop_menus = copy.deepcopy(DirBrowser.popmenulist) self.popmenus = makemenu.makepopmenu(self, pop_menus) self.dirmenu_ids = [self.IDPM_ADD_DIRS] wx.EVT_UPDATE_UI(self, self.IDPM_CUT, self.OnUpdateUI) wx.EVT_UPDATE_UI(self, self.IDPM_COPY, self.OnUpdateUI) wx.EVT_UPDATE_UI(self, self.IDPM_PASTE, self.OnUpdateUI) wx.EVT_UPDATE_UI(self, self.IDPM_CLOSE, self.OnUpdateUI) wx.EVT_UPDATE_UI(self, self.IDPM_ADDFILE, self.OnUpdateUI) wx.EVT_UPDATE_UI(self, self.IDPM_ADDPATH, self.OnUpdateUI) wx.EVT_UPDATE_UI(self, self.IDPM_DELETE, self.OnUpdateUI) wx.EVT_UPDATE_UI(self, self.IDPM_REFRESH, self.OnUpdateUI) wx.EVT_UPDATE_UI(self, self.IDPM_RENAME, self.OnUpdateUI) wx.EVT_UPDATE_UI(self, self.IDPM_IGNORETHIS, self.OnUpdateUI) wx.EVT_UPDATE_UI(self, self.IDPM_IGNORETHISTYPE, self.OnUpdateUI) wx.EVT_UPDATE_UI(self, self.IDPM_OPENDEFAULT, self.OnUpdateUI) wx.EVT_UPDATE_UI(self, self.IDPM_SETPROJ, self.OnUpdateUI) wx.EVT_UPDATE_UI(self, self.IDPM_COMMANDLINE, self.OnUpdateUI) wx.EVT_UPDATE_UI(self, self.IDPM_PRINTDIR, self.OnUpdateUI) self.popmenus = None if dirs: for i in dirs: self.addpath(i, False) self.callplugin('init', self)