我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.EVT_SIZE。
def BindEvents(self): self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_ERASE_BACKGROUND, lambda e: None) self.Bind(wx.EVT_RIGHT_DOWN, self.OnButtonDown) self.Bind(wx.EVT_LEFT_DOWN, self.OnButtonDown) self.Bind(wx.EVT_MIDDLE_DOWN, self.OnButtonDown) self.Bind(wx.EVT_RIGHT_UP, self.OnButtonUp) self.Bind(wx.EVT_LEFT_UP, self.OnButtonUp) self.Bind(wx.EVT_MIDDLE_UP, self.OnButtonUp) self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel) self.Bind(wx.EVT_MOTION, self.OnMotion) self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) self.Bind(wx.EVT_CHAR, self.OnKeyDown) self.Bind(wx.EVT_KEY_UP, self.OnKeyUp) if wx.Platform == "__WXGTK__": # wxGTK requires that the window be created before you can # set its shape, so delay the call to SetWindowShape until # this event. self.Bind(wx.EVT_WINDOW_CREATE, self.OnWindowCreate) else: # On wxMSW and wxMac the window has already been created. self.Bind(wx.EVT_SIZE, self.OnSize) if _useCapture and hasattr(wx, 'EVT_MOUSE_CAPTURE_LOST'): self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self.OnMouseCaptureLost)
def __init__(self, parent): wx.Panel.__init__(self, parent) imageFile = 'Tile.bmp' self.bmp = wx.Bitmap(imageFile) # react to a resize event and redraw image parent.Bind(wx.EVT_SIZE, self.canvasCallback) menu = wx.Menu() menu.Append(wx.ID_ABOUT, "About", "wxPython GUI") menu.AppendSeparator() menu.Append(wx.ID_EXIT, "Exit", " Exit the GUI") menuBar = wx.MenuBar() menuBar.Append(menu, "File") parent.SetMenuBar(menuBar) self.textWidget = wx.TextCtrl(self, size=(280, 80), style=wx.TE_MULTILINE) button = wx.Button(self, label="Create OpenGL 3D Cube", pos=(60, 100)) self.Bind(wx.EVT_BUTTON, self.buttonCallback, button) parent.CreateStatusBar()
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 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(COL_STATUS, "Status") self.listCtrl.InsertColumn(COL_DATE, "Date") self.listCtrl.InsertColumn(COL_FROM, "From") self.listCtrl.InsertColumn(COL_MESSAGE, "Message") ColumnSorterMixin.__init__(self, 4) 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_RIGHT_DOWN(self.listCtrl, self.OnRightDown) wx.EVT_LEFT_DCLICK(self.listCtrl, self.OnPopupEdit) wx.EVT_CLOSE(self, self.closeWindow) # 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 __init__(self, parent, id=wx.ID_ANY, style=wx.ST_SIZEGRIP, name="EnhancedStatusBar"): """Default Class Constructor. EnhancedStatusBar.__init__(self, parent, id=wx.ID_ANY, style=wx.ST_SIZEGRIP, name="EnhancedStatusBar") """ wx.StatusBar.__init__(self, parent, id, style, name) self._items = {} self._curPos = 0 self._parent = parent wx.EVT_SIZE(self, self.OnSize) wx.CallAfter(self.OnSize, None)
def __init__(self, parent,**kwargs): wx.Panel.__init__(self,parent,**kwargs) self.parent = parent self.figure = matplotlib.figure.Figure() self.canvas = wxaggb.FigureCanvasWxAgg(self, -1, self.figure) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.Bind(wx.EVT_SIZE, self.sizeHandler) # canvas is your canvas, and root is your parent (Frame, TopLevel, Tk instance etc.) #self.zoomhandle = wxaggb.NavigationToolbar2WxAgg(self.canvas) #self.toolbar = wxb.NavigationToolbar2Wx(self.canvas) #self.toolbar.Realize() #self.toolbar.update() self.cmap = matplotlib.cm.RdYlBu_r
def __init__(self,title): super(Frame,self).__init__(None,-1,title,style=wx.DEFAULT_FRAME_STYLE^wx.MAXIMIZE_BOX^wx.RESIZE_BORDER) self.colors = {0:(204,192,179),2:(238, 228, 218),4:(237, 224, 200),8:(242, 177, 121),16:(245, 149, 99),32:(246, 124, 95),64:(246, 94, 59),128:(237, 207, 114),256:(237, 207, 114),512:(237, 207, 114),1024:(237, 207, 114),2048:(237, 207, 114),4096:(237, 207, 114),8192:(237, 207, 114),16384:(237, 207, 114),32768:(237, 207, 114),65536:(237, 207, 114),131072:(237, 207, 114),262144:(237, 207, 114),524288:(237, 207, 114),1048576:(237, 207, 114),2097152:(237, 207, 114),4194304:(237, 207, 114),8388608:(237, 207, 114),16777216:(237, 207, 114)}#????????? self.setIcon() self.initGame() self.initBuffer() panel = wx.Panel(self) #?????? #------???? panel.Bind(wx.EVT_KEY_DOWN,self.onKeyDown) panel.SetFocus() #????? self.Bind(wx.EVT_SIZE,self.onSize) #use wx.BufferedPaintDC self.Bind(wx.EVT_PAINT,self.onPaint) self.Bind(wx.EVT_CLOSE,self.onClose) #???? #------ self.SetClientSize((505,720)) #?????? self.Center() #????? self.Show()
def __init__(self, parent): wx.Control.__init__(self, parent) main_sizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0) main_sizer.AddGrowableCol(0) main_sizer.AddGrowableRow(0) # create location text control self.Location = wx.TextCtrl(self, size=wx.Size(0, -1), style=wx.TE_PROCESS_ENTER) self.Location.Bind(wx.EVT_KEY_DOWN, self.OnLocationChar) main_sizer.AddWindow(self.Location, flag=wx.GROW) # create browse button self.BrowseButton = wx.Button(self, label='...', size=wx.Size(30, -1)) self.BrowseButton.Bind(wx.EVT_BUTTON, self.OnBrowseButtonClick) main_sizer.AddWindow(self.BrowseButton, flag=wx.GROW) self.Bind(wx.EVT_SIZE, self.OnSize) self.SetSizer(main_sizer) self.Controller = None self.VarType = None self.Default = False
def __init__(self, parent): wx.Control.__init__(self, parent) main_sizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0) main_sizer.AddGrowableCol(0) main_sizer.AddGrowableRow(0) # create location text control self.Duration = wx.TextCtrl(self, size=wx.Size(0, -1), style=wx.TE_PROCESS_ENTER) self.Duration.Bind(wx.EVT_KEY_DOWN, self.OnDurationChar) main_sizer.AddWindow(self.Duration, flag=wx.GROW) # create browse button self.EditButton = wx.Button(self, label='...', size=wx.Size(30, -1)) self.Bind(wx.EVT_BUTTON, self.OnEditButtonClick, self.EditButton) main_sizer.AddWindow(self.EditButton, flag=wx.GROW) self.Bind(wx.EVT_SIZE, self.OnSize) self.SetSizer(main_sizer) self.Default = None
def __init__(self, parent, manager=None): attribList = attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribList) self.init = False self.context = glcanvas.GLContext(self) self.manager = self.manager = Manager() if manager is None else manager self.size = None self.SetBackgroundStyle(wx.BG_STYLE_PAINT) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp) self.Bind(wx.EVT_MOTION, self.OnMouseMotion) self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel) self.lastx, self.lasty = None, None self.update = True #print('init===========')
def __init__(self, *args, **kwds): # begin wxGlade: help_window.__init__ kwds["style"] = wx.MAXIMIZE | wx.CLOSE_BOX | wx.THICK_FRAME|wx.CAPTION wx.Dialog.__init__(self, *args, **kwds) self.window_1 = wx.SplitterWindow(self, wx.ID_ANY, style=wx.SP_3D | wx.SP_BORDER) self.window_1_pane_left = wx.Panel(self.window_1, wx.ID_ANY) self.html_left = html.HtmlWindow(self.window_1_pane_left, wx.ID_ANY, size=(1, 1)) self.window_1_pane_right = wx.Panel(self.window_1, wx.ID_ANY) self.html_right = html.HtmlWindow(self.window_1_pane_right, wx.ID_ANY, size=(1, 1)) #self.Bind(wx.EVT_COself.on_hyperlink,self.html_left) self.Bind(wx.html.EVT_HTML_LINK_CLICKED,self.on_hyperlink,self.html_left) #self.Bind(wx.EVT_SIZE,self.on_resize) self.__set_properties() self.__do_layout() #self.on_resize(None) self.load_htmlpage() # end wxGlade
def __init__(self): wx.ScrolledWindow.__init__(self) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnResized) self.Bind(wx.EVT_SCROLLWIN, self.OnScrolled) # OnCreate required to avoid crashing wx in xrc creation self.Bind(wx.EVT_WINDOW_CREATE, self.OnCreate) # Disable physical scrolling - refresh entire display on each scroll event. self.EnableScrolling(False, False) # This line enables double-buffered painting for reduced flicker. self.SetBackgroundStyle(wx.BG_STYLE_PAINT) # The previous scroll action (for maintaining viewport during resizes). self.prev_scroll = None self.layout = HexViewLayout()
def __init__(self, controller_uid): TopLevel.__init__(self, controller_uid) UIM = UIManager() controller = UIM.get(self._controller_uid) wx.Dialog.__init__(self, None, wx.ID_ANY, controller.model.title, pos=controller.model.pos, size=controller.model.size, style=controller.model.style ) self._objects = {} if controller.model.icon: self.icon = wx.Icon(controller.model.icon, wx.BITMAP_TYPE_ICO) self.SetIcon(self.icon) if controller.model.maximized: self.Maximize() self.Bind(wx.EVT_MAXIMIZE, self.on_maximize) self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_MOVE, self.on_move) dialog_box = wx.BoxSizer(wx.VERTICAL) self.SetSizer(dialog_box) self.mainpanel = self.AddCreateContainer('BoxSizer', self, proportion=1, flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.EXPAND, border=10 ) button_sizer = self.CreateButtonSizer(controller.model.flags) dialog_box.Add(button_sizer, flag=wx.ALIGN_CENTER|wx.TOP|wx.BOTTOM, border=10) dialog_box.Layout()
def _SizeComponent(self): #print '_SizeComponent' if not self._windows: self.SetSize([0, self.GetSize().GetHeight()]) # #print ' self.SetSize([{}, {}])'.format(0, self.GetSize().GetHeight()) #self.Unbind(wx.EVT_SIZE) elif self._GetFit(): self.SetSize([self.GetParent().GetClientSize().GetWidth(), self.GetSize().GetHeight()]) else: soma = self._LarguraUtil() soma += self._border_size soma += len(self.get_windows_shown()) * self._sash_size self.SetSize([soma, self.GetSize().GetHeight()]) # #print ' self.SetSize([{}, {}])'.format(soma, self.GetSize().GetHeight()) #self.Bind(wx.EVT_SIZE, self._OnSize) self._SizeWindows()
def __init__(self, parent): glcanvas.GLCanvas.__init__(self, parent, -1) self.context = glcanvas.GLContext(self) self.init = False # Cube 3D start rotation self.last_X = self.x = 30 self.last_Y = self.y = 30 self.Bind(wx.EVT_SIZE, self.sizeCallback) self.Bind(wx.EVT_PAINT, self.paintCallback) self.Bind(wx.EVT_LEFT_DOWN, self.mouseDownCallback) self.Bind(wx.EVT_LEFT_UP, self.mouseUpCallback) self.Bind(wx.EVT_MOTION, self.mouseMotionCallback)
def __init__(self, parent): glcanvas.GLCanvas.__init__(self, parent, -1) self.init = False self.context = glcanvas.GLContext(self) # <== this was missing when I wrote the book in 2015... # initial mouse position self.lastx = self.x = 30 self.lasty = self.y = 30 self.size = None self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp) self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
def __init__(self, parent, obj=None, mouse_callback=None, select_callback=None): wx.Panel.__init__(self, parent) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp) self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown) self.Bind(wx.EVT_RIGHT_UP, self.OnMouseUp) self.Bind(wx.EVT_MOTION, self.OnMotion) self.Bind(wx.EVT_SIZE, self.OnSize) self.refresh_from_selection = False self.background_bitmap = None self.obj = obj self.selstart = self.selend = self.movepos = None self.moveSelection = False self.createSelection = False self.begin = 0 if self.obj is not None: self.chnls = len(self.obj) self.end = self.obj.getDur(False) else: self.chnls = 1 self.end = 1.0 self.img = [[]] self.mouse_callback = mouse_callback self.select_callback = select_callback if sys.platform == "win32" or sys.platform.startswith("linux"): self.dcref = wx.BufferedPaintDC else: self.dcref = wx.PaintDC self.setImage() #FL 02/10/2017 self.playCursorPos = 0
def init_gl(self): print('creating Frame') self.window = wx.Frame ( parent=None, id=wx.ID_ANY, title=self.title, style=wx.DEFAULT_FRAME_STYLE|wx.WS_EX_PROCESS_IDLE ) print('creating GLCanvas') self.canvas = glcanvas.GLCanvas ( self.window, glcanvas.WX_GL_RGBA ) print('creating GLContext') self.context = glcanvas.GLContext(self.canvas) self.canvas.SetFocus() self.window.SetSize ( (self.renderer.window_size[0], self.renderer.window_size[1]) ) print('showing Frame') self.window.Show(True) print('calling SetTopWindow') self.SetTopWindow(self.window) self.Bind ( wx.EVT_CHAR, self.OnChar ) self.canvas.Bind ( wx.EVT_SIZE, self.OnCanvasSize ) self.canvas.Bind ( wx.EVT_PAINT, self.OnCanvasPaint ) wx.IdleEvent.SetMode ( wx.IDLE_PROCESS_SPECIFIED ) self.Bind ( wx.EVT_IDLE, self.OnIdle ) print('making context current') self.canvas.SetCurrent ( self.context ) self.renderer.init_gl()
def OnSize(self, event): """ Handles the ``wx.EVT_SIZE`` event for :class:`ImageContainerBase`. :param `event`: a :class:`SizeEvent` event to be processed. """ self.Refresh() # Call on paint event.Skip()
def OnSize(self, event): """ Handles the ``wx.EVT_SIZE`` event for :class:`ImageContainer`. :param `event`: a :class:`SizeEvent` event to be processed. """ ImageContainerBase.OnSize(self, event) event.Skip()
def _unbindfuncs(self): # I would need a list of the functions that been bound to unbind them while True: try: widget, event, dynboundmethod = self._dynbindings.pop() except IndexError: break # no more items in the list else: if event in [wx.EVT_MENU, wx.EVT_TOOL]: self.Unbind(event, handler=dynboundmethod, id=widget.GetId()) elif event in [wx.EVT_SIZE]: self.Unbind(event, handler=dynboundmethod) else: widget.Unbind(event, handler=dynboundmethod)
def _bindfuncs(self): # wx classes throw exception if getmember is applied to the instance (self) methods = inspect.getmembers(self.__class__, inspect.ismethod) for mname, method in methods: dynbindings = getattr(method, '_dynbinding', None) if dynbindings is None: continue for dynbinding in dynbindings: if dynbinding: eventname, widgetprefix, widgetname = dynbinding event = getattr(wx, eventname, None) if event is None: print 'Method', mname print 'Failed to find eventname', eventname continue name = 'm_' + widgetprefix.lower() + widgetname.lower() widget = None for attrname in dir(self): if attrname.lower() == name: widget = getattr(self, attrname) break if not widget: print 'Method', mname print 'Failed to find widget', name continue boundmethod = method.__get__(self, self.__class__) self._dynbindings.append((widget, event, boundmethod)) if event in [wx.EVT_MENU, wx.EVT_TOOL]: self.Bind(event, boundmethod, id=widget.GetId()) elif event in [wx.EVT_SIZE]: self.Bind(event, boundmethod) else: widget.Bind(event, boundmethod)
def initCanvas(self): """Initialize a new matplotlib canvas, figure and axis. """ self.plotPanel = wx.Panel(self) self.plotPanel.SetBackgroundColour('white') plotSizer = wx.BoxSizer(orient=wx.VERTICAL) self.plotPanel.SetSizer(plotSizer) self.fig = plt.Figure(facecolor='white') #self.canvas = FigureCanvas(parent=self, id=wx.ID_ANY, figure=self.fig) self.canvas = FigureCanvas(parent=self.plotPanel, id=wx.ID_ANY, figure=self.fig) self.ax = self.fig.add_subplot(1,1,1) self.ax.set_xlabel('Time (s)') self.ax.set_ylabel('Frequency (Hz)') self.cbAx = self.fig.add_axes([0.91, 0.05, 0.03, 0.93]) #self.fig.subplots_adjust(hspace=0.0, wspace=0.0, # left=0.035, right=0.92, top=0.98, bottom=0.05) self.adjustMargins() self.firstPlot() self.lastSize = (0,0) self.needsResizePlot = True self.canvas.Bind(wx.EVT_SIZE, self.resizePlot) self.canvas.Bind(wx.EVT_IDLE, self.idleResizePlot) ##self.plotToolbar = widgets.PyPlotNavbar(self.canvas) ##plotSizer.Add(self.plotToolbar, proportion=0, flag=wx.EXPAND) plotSizer.Add(self.canvas, proportion=1, flag=wx.EXPAND) #self.plotToolbar.Hide()
def initResponse(self): self.freqResponseFig = plt.Figure() self.freqResponseCanvas = FigureCanvas(parent=self, id=wx.ID_ANY, figure=self.freqResponseFig) self.freqResponseAx = self.freqResponseFig.add_subplot(1,1,1) #self.freqResponseFig.tight_layout() self.phaseResponseFig = plt.Figure() self.phaseResponseCanvas = FigureCanvas(parent=self, id=wx.ID_ANY, figure=self.phaseResponseFig) self.phaseResponseAx = self.phaseResponseFig.add_subplot(1,1,1) #self.freqResponseFig.tight_layout() responseSizer = wx.BoxSizer(wx.VERTICAL) freqResponseControlBox = widgets.ControlBox(self, label='Freqency Response', orient=wx.VERTICAL) freqResponseControlBox.Add(self.freqResponseCanvas, proportion=1, flag=wx.ALL | wx.EXPAND, border=8) responseSizer.Add(freqResponseControlBox, proportion=1, flag=wx.TOP | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=10) phaseResponseControlBox = widgets.ControlBox(self, label='Phase Response', orient=wx.VERTICAL) phaseResponseControlBox.Add(self.phaseResponseCanvas, proportion=1, flag=wx.ALL | wx.EXPAND, border=8) responseSizer.Add(phaseResponseControlBox, proportion=1, flag=wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=10) self.bottomSizer.Add(responseSizer, proportion=1, flag=wx.EXPAND) self.freqResponseCanvas.SetMinSize((0,0)) self.phaseResponseCanvas.SetMinSize((0,0)) # could we prevent resize when panel is not visible? XXX - idfah self.freqResponseLastSize = (0,0) self.freqResponseCanvas.Bind(wx.EVT_SIZE, self.freqResponseResize) self.phaseResponseLastSize = (0,0) self.phaseResponseCanvas.Bind(wx.EVT_SIZE, self.phaseResponseResize) self.updateResponse()
def __init__(self, parent, background='black', style=0, *args, **kwargs): """Initialize a new DrawablePanel. Args: parent: wx parent object. style: Style arguments passed the the wx.Panel base class. The wx.NO_FULL_REPAINT_ON_RESIZE argument is added to the given style arguments. args, kwargs: Additional arguments passed to the wx.Panel base class. """ wx.Panel.__init__(self, parent=parent, style=style | wx.NO_FULL_REPAINT_ON_RESIZE, *args, **kwargs) self.background = background self.lastSize = (0,0) # initial resize creates initial drawing # buffer and triggers first draw self.resize() self.Bind(wx.EVT_PAINT, self.repaint) self.Bind(wx.EVT_SIZE, self.resize)
def __init__(self, *args, **kwargs): wxplt.PlotCanvas.__init__(self, *args, **kwargs) self.lastSize = (0,0) self.Bind(wx.EVT_SIZE, self.resizeHack)
def __init__(self, parent, dpi=None, **kwargs): wx.Panel.__init__(self, parent, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, **kwargs) self.ztv_frame = self.GetTopLevelParent() self.figure = Figure(dpi=None, figsize=(1.,1.)) self.axes = self.figure.add_subplot(111) self.canvas = FigureCanvasWxAgg(self, -1, self.figure) self.Bind(wx.EVT_SIZE, self._onSize)
def __init__(self, parent, dpi=None, **kwargs): wx.Panel.__init__(self, parent, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, **kwargs) self.ztv_frame = self.GetTopLevelParent() self.figure = Figure(dpi=None, figsize=(1.,1.)) self.axes = self.figure.add_subplot(111) self.canvas = FigureCanvasWxAgg(self, -1, self.figure) self.Bind(wx.EVT_SIZE, self._onSize) self.axes_widget = AxesWidget(self.figure.gca()) self.axes_widget.connect_event('motion_notify_event', self.on_motion) self.axes_widget.connect_event('button_press_event', self.on_button_press) self.axes_widget.connect_event('button_release_event', self.on_button_release) self.axes_widget.connect_event('figure_leave_event', self.on_cursor_leave) self.button_down = False
def __init__(self, parent): """Constructor""" wx.Panel.__init__(self, parent=parent) self.gd = GD.Grid(self) self.gd.CreateGrid(20, 2) self.gd.SetRowLabelSize(0) self.gd.SetColLabelSize(0) self.B = wx.StaticBox(self, -1, "Node Detail") BSizer = wx.StaticBoxSizer(self.B, wx.VERTICAL) BSizer.Add(self.gd, 1, wx.EXPAND|wx.ALL) self.SetSizer(BSizer) pub.subscribe(self.updateNodeDetail, "updateNodeDetail") pub.subscribe(self.updateXPath, "updateXPath") self.Bind(wx.EVT_SIZE, self.ResizeGrid)
def __init__(self, parent): attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24) glcanvas.GLCanvas.__init__(self, parent, -1, attribList = attribs) self.context = glcanvas.GLContext(self) self.parent = parent #Camera state variables self.size = self.GetClientSize() #self.camera = MouseSphericalCamera(self.size.x, self.size.y) self.camera = MousePolarCamera(self.size.width, self.size.height) #Main state variables self.MousePos = [0, 0] self.bbox = BBox3D() #Face mesh variables and manipulation variables self.mesh = None self.meshCentroid = None self.displayMeshFaces = True self.displayMeshEdges = False self.displayMeshVertices = True self.displayVertexNormals = False self.displayFaceNormals = False self.useLighting = True self.useTexture = False self.GLinitialized = False #GL-related events wx.EVT_ERASE_BACKGROUND(self, self.processEraseBackgroundEvent) wx.EVT_SIZE(self, self.processSizeEvent) wx.EVT_PAINT(self, self.processPaintEvent) #Mouse Events wx.EVT_LEFT_DOWN(self, self.MouseDown) wx.EVT_LEFT_UP(self, self.MouseUp) wx.EVT_RIGHT_DOWN(self, self.MouseDown) wx.EVT_RIGHT_UP(self, self.MouseUp) wx.EVT_MIDDLE_DOWN(self, self.MouseDown) wx.EVT_MIDDLE_UP(self, self.MouseUp) wx.EVT_MOTION(self, self.MouseMotion)
def __init__(self, parent, file): super(WaveformPlot, self).__init__(parent=parent, title="pyjam Waveform Viewer", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.file = file self.plot = plot.PlotCanvas(self) self.plot.canvas.Bind(wx.EVT_LEFT_DOWN, self.lmb_down) self.plot.canvas.Bind(wx.EVT_LEFT_UP, self.lmb_up) self.plot.canvas.Bind(wx.EVT_MOTION, self.mouse_motion) self.plot.EnableAxesValues = (True, False, False, False) self.plot.EnableGrid = (True, False) self.plot.AbsScale = (True, False) self.plot.EnableAntiAliasing = True self.panel = WaveformPanel(self) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.plot, 1, wx.EXPAND, 0) sizer.Add(self.panel, 0, wx.EXPAND, 0) self.SetSizerAndFit(sizer) self.SetSize(800, self.GetSize()[1]) self.SetMinSize(self.GetSize()) self.player = wx.media.MediaCtrl(parent=self, style=wx.SIMPLE_BORDER) self.volume = 25 self.selected = np.array([0.0, 0.0]) self.maximum = 0.0 self.minimum = 0.0 self.selection_drawn = False self.resized = False self.timer = wx.Timer(self) self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_TIMER, self.on_timer) self.Bind(wx.EVT_IDLE, self.on_idle) self.Bind(wx.EVT_CLOSE, self.on_exit) self.load()
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.NO_BORDER): wx.Panel.__init__(self, parent, id=id, pos=pos, size=size, style=style) self.Viewport = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.NO_BORDER) self.Scrollbar = wx.ScrollBar(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.SB_VERTICAL) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.Viewport, 1, wx.EXPAND, 0) sizer.Add(self.Scrollbar, 0, wx.EXPAND, 0) self.SetSizer(sizer) self.Layout() sizer.Fit(self) self._presenter = Presenter.from_window(self.Viewport.GetHandle(), config.SCALE) self._graphics = None self._font = None self._entities = None self._selected_index = -1 self.Viewport.Bind(wx.EVT_PAINT, self.paint) self.Viewport.Bind(wx.EVT_SIZE, self.resize) self.Viewport.Bind(wx.EVT_MOUSEWHEEL, self.mouse_wheel) self.Viewport.Bind(wx.EVT_LEFT_DOWN, self.mouse_left_down) self.Scrollbar.Bind(wx.EVT_SCROLL, self.scroll)
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.NO_BORDER): wx.Panel.__init__(self, parent, id=id, pos=pos, size=size, style=style) self.Viewport = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.NO_BORDER) self.Scrollbar = wx.ScrollBar(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.SB_VERTICAL) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.Viewport, 1, wx.EXPAND, 0) sizer.Add(self.Scrollbar, 0, wx.EXPAND, 0) self.SetSizer(sizer) self.Layout() sizer.Fit(self) self.Scrollbar.SetScrollbar(0, 0, 0, 0) self._presenter = Presenter.from_window(self.Viewport.GetHandle(), config.SCALE) self._camera = Camera(0, 0, 0, 0) self._tilemap = None self._tileset = None self._select_start = None self._select_end = None self._show_collision = False self.Viewport.Bind(wx.EVT_PAINT, self.paint) self.Viewport.Bind(wx.EVT_SIZE, self.resize) self.Viewport.Bind(wx.EVT_MOUSEWHEEL, self.mouse_wheel) self.Viewport.Bind(wx.EVT_LEFT_DOWN, self.mouse_left_down) self.Viewport.Bind(wx.EVT_LEFT_UP, self.mouse_left_up) self.Viewport.Bind(wx.EVT_MOTION, self.mouse_move) self.Scrollbar.Bind(wx.EVT_SCROLL, self.scroll)
def __init__(self, parent, size): wx.Panel.__init__(self, parent, size=size) self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) self.Bind(wx.EVT_MOTION, self.OnMotion) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_SIZE, self.OnResize) self.ThumbPosition = 0. # -1 <= ThumbPosition <= 1 self.ThumbScrollingStartPos = None
def __init__(self, parent, window, items=[]): """ Constructor @param parent: Parent wx.Window of DebugVariableText @param window: Reference to the Debug Variable Panel @param items: List of DebugVariableItem displayed by Viewer """ DebugVariableViewer.__init__(self, window, items) wx.Panel.__init__(self, parent) # Set panel background colour self.SetBackgroundColour(wx.WHITE) # Define panel drop target self.SetDropTarget(DebugVariableTextDropTarget(self, window)) # Bind events self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick) self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) self.Bind(wx.EVT_SIZE, self.OnResize) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_PAINT, self.OnPaint) # Define panel min size for parent sizer layout self.SetMinSize(wx.Size(0, 25)) # Add buttons to Viewer for bitmap, callback in [("force", self.OnForceButton), ("release", self.OnReleaseButton), ("delete_graph", self.OnCloseButton)]: self.Buttons.append(GraphButton(0, 0, bitmap, callback))
def __init__(self, parent ): wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size(256,81), style = wx.TAB_TRAVERSAL ) self.init_buf() self.his = None self.update = False self.x1, self.x2 = 0, 255 self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_IDLE, self.on_idle) self.Bind(wx.EVT_PAINT, self.on_paint)
def bindEvents(self): for event, handler in [ \ (wx.EVT_SIZE, self.on_size), (wx.EVT_MOUSE_EVENTS, self.on_mouseevent), # Draw (wx.EVT_IDLE, self.on_idle), (wx.EVT_PAINT, self.on_paint)]: # Start drawing]: self.Bind(event, handler)
def __init__(self, parent): wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size(256,80), style = wx.SIMPLE_BORDER|wx.TAB_TRAVERSAL ) self.init_buf() self.data, self.extent = [], [0,0,1,1] self.set_title_label('Graph', 'X-unit', 'Y-unit') self.update = False self.SetBackgroundColour( wx.Colour( 255, 255, 255 ) ) self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_PAINT, self.on_paint) self.Bind(wx.EVT_IDLE, self.on_idle) self.Bind(wx.EVT_MOTION, self.on_move )
def __init__(self, parent, filetypes, fileLimit = None): wx.Dialog.__init__(self, parent, -1, title = 'Select Input Files', style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.filetypes = {} self.fileArray = wx.ListCtrl(self, -1, style = wx.LC_REPORT | wx.LC_EDIT_LABELS | wx.LC_HRULES | wx.LC_VRULES) for i, (filetype, ext) in enumerate(filetypes): self.fileArray.InsertColumn(i, filetype) assert filetype not in self.filetypes, "Non-unique file identifiers! %s" % filetype self.filetypes[filetype] = ext self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.getFile, self.fileArray) self.goButton = wx.Button(self, -1, "Use Selected Files") self.Bind(wx.EVT_BUTTON, self.complete, self.goButton) self.Bind(wx.EVT_CLOSE, self.abort) box = wx.BoxSizer(wx.VERTICAL) box.Add(self.fileArray, 1, wx.ALL | wx.EXPAND, 10) box.Add(self.goButton, 0, wx.ALL | wx.EXPAND, 10) self.SetSizerAndFit(box) self.SetSize(wx.Size(1200, 300)) self.Bind(wx.EVT_SIZE, self.resize) for i in range(0, 10): self.fileArray.Append([''] * self.fileArray.GetColumnCount()) self.resize(None) self.CentreOnScreen()
def __init__( self, parent=None, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL|wx.NO_BORDER|wx.FULL_REPAINT_ON_RESIZE, name='SquareMap', model = None, adapter = None, labels = True, # set to True to draw textual labels within the boxes highlight = True, # set to False to turn of highlighting padding = 2, # amount to reduce the children's box from the parent's box ): super( SquareMap, self ).__init__( parent, id, pos, size, style, name ) self.model = model self.padding = padding self.labels = labels self.highlight = highlight self.selectedNode = None self.highlightedNode = None self.Bind( wx.EVT_PAINT, self.OnPaint) self.Bind( wx.EVT_SIZE, self.OnSize ) if highlight: self.Bind( wx.EVT_MOTION, self.OnMouse ) self.Bind( wx.EVT_LEFT_UP, self.OnClickRelease ) self.Bind( wx.EVT_LEFT_DCLICK, self.OnDoubleClick ) self.Bind( wx.EVT_KEY_UP, self.OnKeyUp ) self.hot_map = [] self.adapter = adapter or DefaultAdapter() self.DEFAULT_PEN = wx.Pen( wx.BLACK, 1, wx.SOLID ) self.SELECTED_PEN = wx.Pen( wx.WHITE, 2, wx.SOLID ) self.OnSize(None)
def __init__(self): wx.Frame.__init__(self, parent=None, id=wx.ID_ANY, title='Janet', size=(WIDTH, HEIGHT)) self.SetMinSize((WIDTH, HEIGHT)) self.browser = None global g_count_windows g_count_windows += 1 self.setup_icon() # self.create_menu() self.Bind(wx.EVT_CLOSE, self.OnClose) # Set wx.WANTS_CHARS style for the keyboard to work. # This style also needs to be set for all parent controls. self.browser_panel = wx.Panel(self, style=wx.WANTS_CHARS) self.browser_panel.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus) self.browser_panel.Bind(wx.EVT_SIZE, self.OnSize) # On Linux must show before embedding browser, so that handle # is available. if LINUX: self.Show() self.embed_browser() else: self.embed_browser() self.Show() wx.CallLater(500, self.setup_gamepad) # this has to be delayed to make sure the DOM has loaded the list of games
def __init__(self, parent): ScrolledPanel.__init__(self, parent, -1, style=wx.BORDER_STATIC) self.tracks = MultiSplitterWindow(self) vbox = wx.BoxSizer(wx.VERTICAL) self.item = vbox.Add(self.tracks, 1, wx.LEFT) self.SetSizer(vbox) self.ShowScrollbars(wx.SHOW_SB_NEVER, wx.SHOW_SB_ALWAYS) self.SetupScrolling() self.tracks.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self._SashPosChanged) self._tracks_attr = [] self.Bind(wx.EVT_SIZE, self._OnSize)
def PostInit(self): UIM = UIManager() controller = UIM.get(self._controller_uid) parent_controller_uid = UIM._getparentuid(self._controller_uid) parent_controller = UIM.get(parent_controller_uid) parent_controller._create_windows(self._controller_uid) # if controller.model.overview: self.create_depth_canvas() self.reposition_depth_canvas() self.track.Bind(wx.EVT_SIZE, self.on_track_size) self.track.Bind(wx.EVT_MOUSE_EVENTS, self.on_mouse) # self.track.mpl_connect('motion_notify_event', self.on_track_move) controller.subscribe(self._invert_selection, 'change.selected') controller.subscribe(self.change_visibility, 'change.visible') controller.subscribe(self.update_title, 'change.label') #controller.subscribe(self.update_title, 'change.pos') controller.subscribe(self._change_position, 'change.pos') controller.subscribe(self.update_plotgrid, 'change.plotgrid') controller.subscribe(self.update_x_scale, 'change.x_scale') controller.subscribe(self.update_y_major_grid_lines, 'change.y_major_grid_lines') controller.subscribe(self.update_y_minor_grid_lines, 'change.y_minor_grid_lines') controller.subscribe(self.update_depth_lines, 'change.depth_lines') controller.subscribe(self.update_minorgrid, 'change.minorgrid') controller.subscribe(self.update_leftscale, 'change.leftscale') controller.subscribe(self.update_decades, 'change.decades') controller.subscribe(self.update_scale_lines, 'change.scale_lines') self.update_title(None, None)