def __init__(self, parent, ID, label, url): wx.Panel.__init__(self, parent, ID) self.url = url self.text_bg = wx.Panel(self) self.text = wx.StaticText(self.text_bg, label=label) self.clicked = False self.FONT_DEFAULT = self.text.GetFont() self.FONT_HIGHLIGHT = self.text.GetFont() self.FONT_HIGHLIGHT.SetUnderlined(True) wx.EVT_LEFT_DOWN(self.text, self.OnLeftClick) wx.EVT_ENTER_WINDOW(self.text_bg, self.OnMouseOver) wx.EVT_LEAVE_WINDOW(self.text_bg, self.OnMouseOut) self.text.SetForegroundColour(wx.Colour(0, 0, 255)) layout_V1 = BoxSizer(wx.VERTICAL) layout_V1.AddSpacer(1, wx.EXPAND) layout_V1.Add(self.text_bg, 0, wx.ALIGN_CENTER) layout_V1.AddSpacer(1, wx.EXPAND) self.SetAutoLayout(True) self.SetSizer(layout_V1) self.Layout()
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 _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,id=-1,ctrlStyle=(wx.LC_REPORT|wx.LC_SINGLE_SEL)): """Init.""" wx.Panel.__init__(self,parent,id, style=wx.WANTS_CHARS) sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) self.SetSizeHints(-1,50) #--ListCtrl listId = self.listId = wx.NewId() self.list = ListCtrl(self, listId, style=ctrlStyle) self.checkboxes = singletons.images['mash.checkboxes'] #--Columns self.PopulateColumns() #--Items self.sortDirty = 0 self.PopulateItems() self.hitIcon = 0 self.mouseItem = None #--Events wx.EVT_SIZE(self, self.OnSize) wx.EVT_LEFT_DOWN(self.list,self.OnLeftDown) wx.EVT_COMMAND_RIGHT_CLICK(self.list, listId, self.DoItemMenu) wx.EVT_LIST_COL_CLICK(self, listId, self.DoItemSort) wx.EVT_LIST_COL_RIGHT_CLICK(self, listId, self.DoColumnMenu) wx.EVT_LIST_COL_END_DRAG(self, listId, self.OnColumnResize) wx.EVT_MOTION(self.list, self.OnMouse) wx.EVT_LEAVE_WINDOW(self.list, self.OnMouse) # Theming if interface.style['lists.font.color'] is not None: [self.list.SetItemTextColour(x, interface.style['lists.font.color']) for x in xrange(self.list.GetItemCount())] self.fontDefaultColor = interface.style['lists.font.color'] else: self.fontDefaultColor = wx.SystemSettings.GetColour(wx.SYS_COLOUR_LISTBOXTEXT) self.list.Bind(wx.EVT_ENTER_WINDOW, self.hoverInCtrl)
def __init__(self, parent, bitmap, selected=None, handler=None, padding=10): """ Initializes the object. """ wx.Window.__init__(self, parent, -1, size=wx.Size(bitmap.GetWidth() + padding, bitmap.GetHeight() + padding)) self._bitmap = bitmap self._selected = selected self._handler = handler self._mouse_over = False self._button_down = False # Set up the 'paint' event handler: wx.EVT_PAINT(self, self._on_paint) # Set up mouse event handlers: wx.EVT_LEFT_DOWN(self, self._on_left_down) wx.EVT_LEFT_UP(self, self._on_left_up) wx.EVT_ENTER_WINDOW(self, self._on_enter) wx.EVT_LEAVE_WINDOW(self, self._on_leave)
def __init__(self, parent, id, attr=DefaultCalendarCellAttributes, style=wx.SIMPLE_BORDER): wx.PyWindow.__init__(self, parent, id, style=style | wx.WANTS_CHARS | wx.FULL_REPAINT_ON_RESIZE) self.attr = GetCalendarCellAttributes(attr) self.day = 33 self.year = 2033 self.month = 3 self.buffer = None self.needsupdate = True self.entries = () self._tipwindow = None wx.EVT_PAINT(self, self.OnPaint) wx.EVT_SIZE(self, self.OnSize) wx.EVT_ENTER_WINDOW(self, self.OnEnterWindow) wx.EVT_LEAVE_WINDOW(self, self.OnLeaveWindow) self._timer = wx.Timer(self) wx.EVT_TIMER(self, self._timer.GetId(), self.OnTimer) self.OnSize(None)
def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ factory = self.factory # Establish the range of the slider: low, high = factory.low, factory.high if high <= low: low = high = None range = self.object.trait(self.name).handler if isinstance(range, Range): low, high = range._low, range._high if low is None: if high is None: high = 1.0 low = high - 1.0 elif high is None: high = low + 1.0 # Establish the slider increment: increment = factory.increment if increment <= 0.0: if isinstance(low, int): increment = 1.0 else: increment = pow(10, int(log10((high - low) / 1000.0))) # Save the values we calculated: self.set(low=low, high=high, increment=increment) # Create the control: self.control = control = wx.Window(parent, -1, size=wx.Size(70, 20), style=wx.FULL_REPAINT_ON_RESIZE | wx.TAB_TRAVERSAL) # Set up the painting event handlers: wx.EVT_ERASE_BACKGROUND(control, self._erase_background) wx.EVT_PAINT(control, self._on_paint) wx.EVT_SET_FOCUS(control, self._set_focus) # Set up mouse event handlers: wx.EVT_LEFT_DOWN(control, self._left_down) wx.EVT_LEFT_UP(control, self._left_up) wx.EVT_MOTION(control, self._motion) wx.EVT_MOUSEWHEEL(control, self._mouse_wheel) wx.EVT_ENTER_WINDOW(control, self._enter_window) wx.EVT_LEAVE_WINDOW(control, self._leave_window) # Set up the control resize handler: wx.EVT_SIZE(control, self._resize) # Set the tooltip: if not self.set_tooltip(): control.SetToolTipString('[%g..%g]' % (low, high))
def __init__(self, parent, label, whotocall, whotonotify, msg, style): """Expects reference to 'ButtonColumn', list of labels for buttons and list of functions to be called for OnClick events""" id = wx.NewId() wx.TextCtrl.__init__(self, parent, id, style=style) self.whotocall = whotocall self.whotonotify = whotonotify self.msg = msg wx.EVT_BUTTON(self, id, self.OnClick) wx.EVT_ENTER_WINDOW(self, self.OnEnter) wx.EVT_LEAVE_WINDOW(self, self.OnLeave)
def _create_control(self, parent): """ Create the toolkit-specific control that represents the widget. """ collapsed_carat = self.collapsed_carat_image.create_image() self._collapsed_bmp = collapsed_carat.ConvertToBitmap() self._carat_w = self._collapsed_bmp.GetWidth() expanded_carat = self.expanded_carat_image.create_image() self._expanded_bmp = expanded_carat.ConvertToBitmap() header_bar = self.header_bar_image.create_image() self._header_bmp = header_bar.ConvertToBitmap() header_bar_over = self.header_mouseover_image.create_image() self._header_mouseover_bmp = header_bar_over.ConvertToBitmap() self._background_bmp = self._header_bmp close_image = self.remove_image.create_image() self._remove_bmp = close_image.ConvertToBitmap() # create our panel and initialize it appropriately sizer = wx.BoxSizer(wx.VERTICAL) panel = wx.Panel(parent, -1, style=wx.CLIP_CHILDREN) panel.SetSizer(sizer) panel.SetAutoLayout(True) # needed on GTK systems for EVT_ERASE_BACKGROUND to work panel.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) # create the remove button remove = wx.BitmapButton(panel, -1, self._remove_bmp, style=0, pos=(-1, 3)) sizer.Add(remove, 0, wx.ALIGN_RIGHT, 5) # Create a suitable font. self._font = new_font_like(wx.NORMAL_FONT, point_size=wx.NORMAL_FONT.GetPointSize() - 1) height = self._get_preferred_height(parent, self.title, self._font) panel.SetSize((-1, height)) wx.EVT_ERASE_BACKGROUND(panel, self._on_erase_background) wx.EVT_ENTER_WINDOW(panel, self._on_enter_leave) wx.EVT_LEAVE_WINDOW(panel, self._on_enter_leave) wx.EVT_LEFT_DOWN(panel, self._on_down) wx.EVT_RIGHT_DOWN(panel, self._on_down) wx.EVT_BUTTON(panel, remove.GetId(), self._on_remove) return panel
def dispose(self): """ Disposes of the contents of an editor. """ if self.factory.view is not None: control = self.control wx.EVT_ENTER_WINDOW(control, None) wx.EVT_LEAVE_WINDOW(control, None) wx.EVT_LEFT_DOWN(control, None) wx.EVT_LEFT_UP(control, None) super(ReadonlyEditor, self).dispose()
def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ super(ReadonlyEditor, self).init(parent) if self.factory.view is not None: control = self.control wx.EVT_ENTER_WINDOW(control, self._enter_window) wx.EVT_LEAVE_WINDOW(control, self._leave_window) wx.EVT_LEFT_DOWN(control, self._left_down) wx.EVT_LEFT_UP(control, self._left_up)
def __init__(self, parent, **traits): """ Creates a new image control. """ self._image = None super(ImageButton, self).__init__(**traits) # Calculate the size of the button: idx = idy = tdx = tdy = 0 if self._image is not None: idx = self._image.GetWidth() idy = self._image.GetHeight() if self.label != '': dc = wx.ScreenDC() dc.SetFont(wx.NORMAL_FONT) tdx, tdy = dc.GetTextExtent(self.label) wp2 = self.width_padding + 2 hp2 = self.height_padding + 2 if self.orientation == 'horizontal': self._ix = wp2 spacing = (idx > 0) * (tdx > 0) * 4 self._tx = self._ix + idx + spacing dx = idx + tdx + spacing dy = max(idy, tdy) self._iy = hp2 + ((dy - idy) / 2) self._ty = hp2 + ((dy - tdy) / 2) else: self._iy = hp2 spacing = (idy > 0) * (tdy > 0) * 2 self._ty = self._iy + idy + spacing dx = max(idx, tdx) dy = idy + tdy + spacing self._ix = wp2 + ((dx - idx) / 2) self._tx = wp2 + ((dx - tdx) / 2) # Create the toolkit-specific control: self._dx = dx + wp2 + wp2 self._dy = dy + hp2 + hp2 self.control = wx.Window(parent, -1, size=wx.Size(self._dx, self._dy)) self.control._owner = self self._mouse_over = 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_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)
def __init__(self, parent, id=-1, image=None, tailleCadre=(384, 384)): wx.Window.__init__(self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.NO_FULL_REPAINT_ON_RESIZE |wx.SUNKEN_BORDER) self.tailleCadre = tailleCadre self.fichierImageSource = image self.InitImage() # Binds wx.EVT_PAINT(self, self.evt_paint) wx.EVT_SIZE(self, self.evt_size) wx.EVT_KEY_DOWN(self, self.evt_key) wx.EVT_LEFT_DOWN(self, self.evt_mouse) wx.EVT_LEFT_UP(self, self.evt_mouse) wx.EVT_MOTION(self, self.evt_mouse) wx.EVT_LEAVE_WINDOW(self, self.OnLeaveWindow)
def __init__(self,parent): x,y,w,h = self.CalcSizePos(parent) wx.Window.__init__(self,id = -1,parent = parent, pos = wxPoint(x,y), size = wx.Size(w,h), style = wx.CLIP_CHILDREN) self.down = False self.entered = False wx.EVT_LEFT_DOWN(self,self.OnPress) wx.EVT_LEFT_UP(self,self.OnRelease) wx.EVT_PAINT(self,self.OnPaint) wx.EVT_LEAVE_WINDOW(self,self.OnLeave) wx.EVT_ENTER_WINDOW(self,self.OnEnter)
def __init__(self, parent, label, whotocall, whotonotify, msg, image1): """Expects reference to 'ButtonColumn', list of labels for buttons and list of functions to be called for OnClick events""" id = wx.NewId() wx.BitmapButton.__init__(self, parent, id, bitmap=image1, size=(image1.GetWidth() + 6, image1.GetHeight() + 6)) self.whotocall = whotocall self.whotonotify = whotonotify self.msg = msg wx.EVT_BUTTON(self, id, self.OnClick) wx.EVT_ENTER_WINDOW(self, self.OnEnter) wx.EVT_LEAVE_WINDOW(self, self.OnLeave)
def _pop_up_text(self): """ Pop-up a text control to allow the user to enter a value using the keyboard. """ control = self.control self._text = text = wx.TextCtrl(control, -1, self.text, size=control.GetSize(), style=self.text_styles[self.factory.alignment] | wx.TE_PROCESS_ENTER) text.SetSelection(-1, -1) text.SetFocus() wx.EVT_TEXT_ENTER(control, text.GetId(), self._text_completed) wx.EVT_KILL_FOCUS(text, self._text_completed) wx.EVT_ENTER_WINDOW(text, self._enter_text) wx.EVT_LEAVE_WINDOW(text, self._leave_text) wx.EVT_CHAR(text, self._key_entered)
def _pop_up_text(self): control = self.control self._text = text = wx.TextCtrl( control, -1, str(self.value), size=control.GetSize(), style=self.text_styles[self.factory.alignment] | wx.TE_PROCESS_ENTER) text.SetSelection(-1, -1) text.SetFocus() wx.EVT_TEXT_ENTER(control, text.GetId(), self._text_completed) wx.EVT_KILL_FOCUS(text, self._text_completed) wx.EVT_ENTER_WINDOW(text, self._enter_text) wx.EVT_LEAVE_WINDOW(text, self._leave_text) wx.EVT_CHAR(text, self._key_entered)
def __init__(self,parent,side): self.side = side x,y,w,h = self.CalcSizePos(parent) wx.Window.__init__(self,id = -1,parent = parent, pos = wxPoint(x,y), size = wx.Size(w,h), style = wx.CLIP_CHILDREN) self.px = None # Previous X self.py = None # Previous Y self.isDrag = False # In Dragging wx.EVT_LEAVE_WINDOW(self,self.OnLeave) wx.EVT_ENTER_WINDOW(self,self.OnEnter) wx.EVT_MOTION(self,self.OnMouseMove) wx.EVT_LEFT_DOWN(self,self.OnPress) wx.EVT_LEFT_UP(self,self.OnRelease) wx.EVT_PAINT(self,self.OnPaint)
def __init__(self, *args, **kwargs): wx.SashLayoutWindow.__init__(self, *args, **kwargs) self.effectiveSashPos = 0 self.minimalEffectiveSashPos = 0 self.sashPos = 0 self.centerWindow = None self.layoutWorkSize = None self.SetMinimumSizeX(1) self.SetMinimumSizeY(1) wx.EVT_SASH_DRAGGED(self, self.GetId(), self.OnSashDragged) if isLinux(): self._CURSOR_SIZEWE = wx.StockCursor(wx.CURSOR_SIZEWE) self._CURSOR_SIZENS = wx.StockCursor(wx.CURSOR_SIZENS) wx.EVT_MOTION(self, self.MouseMotion) wx.EVT_LEAVE_WINDOW(self, self.OnMouseLeave)
def __init__(self, mainControl, wikiWordFilter): self.mainControl = mainControl # Some object derived from DatedWikiWordFilterBase self.wikiWordFilter = wikiWordFilter self.wikiWordListPopup = None # Shift from upper left corner of selected cell/list item self.popupShiftX = 5 self.popupShiftY = 5 self.labelEdit = False # Is currently a label edit running? # Is control in the top layer? self.layerVisible = True self.sizeVisible = True wx.EVT_MOTION(self, self.OnMouseMotion) wx.EVT_LEAVE_WINDOW(self, self.OnMouseLeave)
def _make_calendar_widget(self, month_offset): """ Add a calendar widget to the screen and hook up callbacks. Parameters ---------- month_offset : int The number of months from today, that the calendar should start at. """ date = self.shift_datetime(self.date, month_offset) panel = wx.Panel(self, -1) cal = wxMouseBoxCalendarCtrl( panel, -1, date, style=wx.calendar.CAL_SUNDAY_FIRST | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION # | wx.calendar.CAL_SHOW_HOLIDAYS ) self.sizer.Add(panel) cal.highlight_changed() # Set up control to sync the other calendar widgets and coloring: self.Bind(wx.calendar.EVT_CALENDAR_MONTH, self.month_changed, cal) self.Bind(wx.calendar.EVT_CALENDAR_YEAR, self.month_changed, cal) wx.EVT_LEFT_DOWN(cal, self._left_down) if self.multi_select: wx.EVT_LEFT_UP(cal, self._left_up) wx.EVT_RIGHT_UP(cal, self._process_box_select) wx.EVT_LEAVE_WINDOW(cal, self._process_box_select) wx.EVT_MOTION(cal, self._mouse_drag) self.Bind( wx.calendar.EVT_CALENDAR_WEEKDAY_CLICKED, self._weekday_clicked, cal, ) return cal
def __init__(self, master, gradient_table, color_space, width, height): """Initialize a function control widget on tkframe master. Parameters: ----------- master: The master widget. Note that this widget *must* have the methods specified in the `AbstractGradientEditorWidget` interface. on_table_changed: Callback function taking a bool argument of meaning 'FinalUpdate'. FinalUpdate is true if a control point is dropped, created or removed and false if the update is due to a control point currently beeing dragged (but not yet dropped) color_space: String which specifies the channels painted on this control. May be any combination of h,s,v,r,g,b,a in which each channel occurs only once. set_status_text: a callback used to set the status text when using the editor. """ FunctionControl.__init__(self, master, gradient_table, color_space, width, height) wx.Panel.__init__(self, master, size=wx.Size(width, height), name="RGBHSVA Editor") self.update() wx.EVT_LEFT_DOWN(self, self.on_left_button_down) wx.EVT_LEFT_UP(self, self.on_left_button_up) wx.EVT_RIGHT_DOWN(self, self.on_right_button_down) wx.EVT_RIGHT_UP(self, self.on_right_button_up) wx.EVT_MOTION(self, self.on_mouse_move) wx.EVT_PAINT(self, self.on_paint) wx.EVT_LEAVE_WINDOW(self, self.on_leave_window)
def __init__(self, parent, wid=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, **traits): AbstractWindow.__init__(self, **traits) self._timer = None self._mouse_captured = False # Due to wx wonkiness, we don't reliably get cursor position from # a wx KeyEvent. Thus, we manually keep track of when we last saw # the mouse and use that information instead. These coordinates are # in the wx coordinate space, i.e. pre-self._flip_y(). self._last_mouse_pos = (0, 0) # Create the delegate: self.control = control = self._create_control(parent, wid, pos, size) # Set up the 'erase background' event handler: wx.EVT_ERASE_BACKGROUND(control, self._on_erase_background) # Set up the 'paint' event handler: wx.EVT_PAINT(control, self._paint) wx.EVT_SIZE(control, self._on_size) # Set up mouse event handlers: wx.EVT_LEFT_DOWN(control, self._on_left_down) wx.EVT_LEFT_UP(control, self._on_left_up) wx.EVT_LEFT_DCLICK(control, self._on_left_dclick) wx.EVT_MIDDLE_DOWN(control, self._on_middle_down) wx.EVT_MIDDLE_UP(control, self._on_middle_up) wx.EVT_MIDDLE_DCLICK(control, self._on_middle_dclick) wx.EVT_RIGHT_DOWN(control, self._on_right_down) wx.EVT_RIGHT_UP(control, self._on_right_up) wx.EVT_RIGHT_DCLICK(control, self._on_right_dclick) wx.EVT_MOTION(control, self._on_mouse_move) wx.EVT_ENTER_WINDOW(control, self._on_window_enter) wx.EVT_LEAVE_WINDOW(control, self._on_window_leave) wx.EVT_MOUSEWHEEL(control, self._on_mouse_wheel) # Handle key up/down events: wx.EVT_KEY_DOWN(control, self._on_key_pressed) wx.EVT_KEY_UP(control, self._on_key_released) wx.EVT_CHAR(control, self._on_character) # Attempt to allow wxPython drag and drop events to be mapped to # Enable drag events: # Handle window close and cleanup wx.EVT_WINDOW_DESTROY(control, self._on_close) if PythonDropTarget is not None: control.SetDropTarget(LessSuckyDropTarget(self)) self._drag_over = [] # In some cases, on the Mac at least, we never get an initial EVT_SIZE # since the initial size is correct. Because of this we call _on_size # here to initialize our bounds. self._on_size(None) return
def __init__(self, parent, mainControl, ID, date, wikiWords, pos=wx.DefaultPosition): if ID == -1: ID = GUI_ID.TIMESHOW_WIKIWORDLIST_POPUP # if _POPUP_PARENT is wx.Frame: wx.Frame.__init__(self, parent, ID, "WikiWordList", pos=pos, style=wx.FRAME_FLOAT_ON_PARENT | self.FRAME_BORDER | wx.FRAME_NO_TASKBAR) # wx.RESIZE_BORDER | # else: # wx.PopupWindow.__init__(self, parent, flags=self.FRAME_BORDER) self.mainControl = mainControl self.wikiWords = wikiWords # Item id of item in parent list self.date = date self.resultBox = EnhancedListControl( self, GUI_ID.TIMESHOW_WIKIWORDLIST, style=wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_NO_HEADER | self.LIST_BORDER) self.resultBox.InsertColumn(0, u"", width=10) self.listContent = wikiWords # Calculate minimal width of list dc = wx.ClientDC(self) try: dc.SetFont(self.resultBox.GetFont()) self._listMinWidth = dc.GetTextExtent(u"MMMMMMMM")[0] dc.SetFont(wx.NullFont) finally: dc = None # self._listMinWidth = 60 sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.resultBox, 1, wx.EXPAND) self.SetSizer(sizer) self.updateList() self.Layout() # Calculate size rect = self.resultBox.GetItemRect(0) setWindowClientSize(self, (rect.x + rect.width, rect.y + 2 + rect.height * len(self.listContent))) # self.SetClientSizeWH(rect.x + rect.width, rect.y + 2 + rect.height * len(self.listContent)) # self.Layout() setWindowPos(self, fullVisible=True) wx.EVT_MIDDLE_DOWN(self.resultBox, self.OnListMiddleButtonDown) wx.EVT_MOTION(self.resultBox, self.OnListMouseMotion) wx.EVT_LEFT_DOWN(self.resultBox, self.OnListLeftButtonDown) wx.EVT_LEAVE_WINDOW(self.resultBox, self.OnListMouseLeave)
def __init__(self, parent, ID, *args, **kw): # miscellaneous protected variables self._CurrentRenderer = None self._CurrentCamera = None self._CurrentZoom = 1.0 self._CurrentLight = None self._ViewportCenterX = 0 self._ViewportCenterY = 0 self._Picker = vtkCellPicker() self._PickedActor = None self._PickedProperty = vtkProperty() self._PickedProperty.SetColor(1, 0, 0) self._PrePickedProperty = None # these record the previous mouse position self._LastX = 0 self._LastY = 0 # the current interaction mode (Rotate, Pan, Zoom, etc) self._Mode = None self._ActiveButton = None # private attributes self.__OldFocus = None # used by the LOD actors self._DesiredUpdateRate = 15 self._StillUpdateRate = 0.0001 # First do special handling of some keywords: # stereo, position, size, width, height, style stereo = 0 if 'stereo' in kw: if kw['stereo']: stereo = 1 del kw['stereo'] position = wx.DefaultPosition if 'position' in kw: position = kw['position'] del kw['position'] size = wx.DefaultSize if 'size' in kw: size = kw['size'] del kw['size'] if 'width' in kw and 'height' in kw: size = (kw['width'], kw['height']) del kw['width'] del kw['height'] # wxWANTS_CHARS says to give us e.g. TAB # wxNO_FULL_REPAINT_ON_RESIZE cuts down resize flicker under GTK style = wx.WANTS_CHARS | wx.NO_FULL_REPAINT_ON_RESIZE if 'style' in kw: style = style | kw['style'] del kw['style'] # the enclosing frame must be shown under GTK or the windows # don't connect together properly l = [] p = parent while p: # make a list of all parents l.append(p) p = p.GetParent() l.reverse() # sort list into descending order for p in l: p.Show() # initialize the wxWindow baseClass.__init__(self, parent, ID, position, size, style) # create the RenderWindow and initialize it self._RenderWindow = vtkRenderWindow() try: self._RenderWindow.SetSize(size.width, size.height) except AttributeError: self._RenderWindow.SetSize(size[0], size[1]) if stereo: self._RenderWindow.StereoCapableWindowOn() self._RenderWindow.SetStereoTypeToCrystalEyes() self.__Created = 0 # Tell the RenderWindow to render inside the wxWindow. if self.GetHandle(): self.__Created = 1 self._RenderWindow.SetWindowInfo(str(self.GetHandle())) # refresh window by doing a Render wx.EVT_PAINT(self, self.OnPaint) # turn off background erase to reduce flicker wx.EVT_ERASE_BACKGROUND(self, lambda e: None) # Bind the events to the event converters wx.EVT_RIGHT_DOWN(self, self._OnButtonDown) wx.EVT_LEFT_DOWN(self, self._OnButtonDown) wx.EVT_MIDDLE_DOWN(self, self._OnButtonDown) wx.EVT_RIGHT_UP(self, self._OnButtonUp) wx.EVT_LEFT_UP(self, self._OnButtonUp) wx.EVT_MIDDLE_UP(self, self._OnButtonUp) wx.EVT_MOTION(self, self.OnMotion) wx.EVT_ENTER_WINDOW(self, self._OnEnterWindow) wx.EVT_LEAVE_WINDOW(self, self._OnLeaveWindow) wx.EVT_CHAR(self, self.OnChar) wx.EVT_KEY_DOWN(self, self.OnKeyDown) wx.EVT_KEY_UP(self, self.OnKeyUp) wx.EVT_SIZE(self, self._OnSize) wx.EVT_MOVE(self, self.OnMove) wx.EVT_SET_FOCUS(self, self.OnSetFocus) wx.EVT_KILL_FOCUS(self, self.OnKillFocus)
def __init__(self, config, calls): self.config = config self.calls = calls self.cancelflag = threading.Event() self.switchlock = threading.Lock() self.working = False self.queue = [] wx.InitAllImageHandlers() self.thostselection = self.calls['getCurrentTHost']() self.thostselectnum = 0 self.choices = None self.choices1 = None self.windowStyle = wx.SYSTEM_MENU | wx.CAPTION | wx.MINIMIZE_BOX if self.config['stayontop']: self.windowStyle |= wx.STAY_ON_TOP frame = wx.Frame(None, -1, 'T-Make', size=wx.Size(-1, -1), style=self.windowStyle) self.frame = frame panel = wx.Panel(frame, -1) fullSizer = wx.FlexGridSizer(cols=1, vgap=0, hgap=8) colSizer = wx.FlexGridSizer(cols=2, vgap=0, hgap=8) leftSizer = wx.FlexGridSizer(cols=1, vgap=3) self.stayontop_checkbox = wx.CheckBox(panel, -1, "stay on top") self.stayontop_checkbox.SetValue(self.config['stayontop']) wx.EVT_CHECKBOX(frame, self.stayontop_checkbox.GetId(), self.setstayontop) leftSizer.Add(self.stayontop_checkbox, -1, wx.ALIGN_CENTER) leftSizer.Add(wx.StaticText(panel, -1, '')) button = wx.Button(panel, -1, 'use image...') wx.EVT_BUTTON(frame, button.GetId(), self.selectDropTarget) leftSizer.Add(button, -1, wx.ALIGN_CENTER) self.groupSizer1Box = wx.StaticBox(panel, -1, '') groupSizer1 = wx.StaticBoxSizer(self.groupSizer1Box, wx.HORIZONTAL) groupSizer = wx.FlexGridSizer(cols=1, vgap=0) self.dropTarget = self.calls['newDropTarget']((200, 200)) # self.dropTarget = self.calls['newDropTarget']() self.dropTargetPtr = wx.StaticBitmap(panel, -1, self.dropTarget) self.calls['setDropTargetRefresh'](self.dropTargetPtr.Refresh) self.dropTargetWidth = self.dropTarget.GetWidth() wx.EVT_LEFT_DOWN(self.dropTargetPtr, self.dropTargetClick) wx.EVT_ENTER_WINDOW(self.dropTargetPtr, self.calls['dropTargetHovered']) wx.EVT_LEAVE_WINDOW(self.dropTargetPtr, self.calls['dropTargetUnhovered']) groupSizer.Add(self.dropTargetPtr, 0, wx.ALIGN_CENTER) lowerSizer1 = wx.GridSizer(cols=3) dirlink = wx.StaticText(panel, -1, 'dir') dirlink.SetFont(wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.NORMAL, True)) dirlink.SetForegroundColour('blue') wx.EVT_LEFT_UP(dirlink, self.selectdir) lowerSizer1.Add(dirlink, -1, wx.ALIGN_LEFT) lowerSizer1.Add(wx.StaticText(panel, -1, ''), -1, wx.ALIGN_CENTER) filelink = wx.StaticText(panel, -1, 'file') filelink.SetFont(wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.NORMAL, True)) filelink.SetForegroundColour('blue') wx.EVT_LEFT_UP(filelink, self.selectfile) lowerSizer1.Add(filelink, -1, wx.ALIGN_RIGHT) groupSizer.Add(lowerSizer1, -1, wx.ALIGN_CENTER) self.gauge = wx.Gauge(panel, -1, range=1000, style=wx.GA_HORIZONTAL, size=(-1, 15)) groupSizer.Add(self.gauge, 0, wx.EXPAND) self.statustext = wx.StaticText(panel, -1, 'ready', style=wx.ALIGN_CENTER | wx.ST_NO_AUTORESIZE) self.statustext.SetFont( wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.BOLD, False)) groupSizer.Add(self.statustext, -1, wx.EXPAND) self.choices = wx.Choice(panel, -1, (-1, -1), (self.dropTargetWidth, -1), choices=[]) self.choices.SetFont( wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False)) wx.EVT_CHOICE(self.choices, -1, self.set_thost) groupSizer.Add(self.choices, 0, wx.EXPAND) cancellink = wx.StaticText(panel, -1, 'cancel') cancellink.SetFont(wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.NORMAL, True)) cancellink.SetForegroundColour('red') wx.EVT_LEFT_UP(cancellink, self.cancel) groupSizer.Add(cancellink, -1, wx.ALIGN_CENTER) dummyadvlink = wx.StaticText(panel, -1, 'advanced') dummyadvlink.SetFont( wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False)) dummyadvlink.SetForegroundColour('blue') wx.EVT_LEFT_UP(dirlink, self.selectdir) groupSizer.Add(dummyadvlink, -1, wx.ALIGN_CENTER) groupSizer1.Add(groupSizer) leftSizer.Add(groupSizer1, -1, wx.ALIGN_CENTER) leftSizer.Add(wx.StaticText(panel, -1, 'make torrent of:'), 0, wx.ALIGN_CENTER) self.dirCtl = wx.TextCtrl(panel, -1, '', size=(250, -1)) leftSizer.Add(self.dirCtl, 1, wx.EXPAND) b = wx.BoxSizer(wx.HORIZONTAL) button = wx.Button(panel, -1, 'dir') wx.EVT_BUTTON(frame, button.GetId(), self.selectdir) b.Add(button, 0) button2 = wx.Button(panel, -1, 'file') wx.EVT_BUTTON(frame, button2.GetId(), self.selectfile) b.Add(button2, 0) leftSizer.Add(b, 0, wx.ALIGN_CENTER) leftSizer.Add(wx.StaticText(panel, -1, '')) simple_link = wx.StaticText(panel, -1, 'back to basic mode') simple_link.SetFont(wx.Font(-1, wx.DEFAULT, wx.NORMAL, wx.NORMAL, True)) simple_link.SetForegroundColour('blue') wx.EVT_LEFT_UP(simple_link, self.calls['switchToBasic']) leftSizer.Add(simple_link, -1, wx.ALIGN_CENTER) colSizer.Add(leftSizer, -1, wx.ALIGN_CENTER_VERTICAL) gridSizer = wx.FlexGridSizer(cols=2, vgap=6, hgap=8) gridSizer.Add(wx.StaticText(panel, -1, 'Torrent host:'), -1, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) self.choices1 = wx.Choice(panel, -1, (-1, -1), (-1, -1), choices=[]) wx.EVT_CHOICE(self.choices1, -1, self.set_thost1) gridSizer.Add(self.choices1, 0, wx.EXPAND) b = wx.BoxSizer(wx.HORIZONTAL) button1 = wx.Button(panel, -1, 'set default') wx.EVT_BUTTON(frame, button1.GetId(), self.set_default_thost) b.Add(button1, 0) b.Add(wx.StaticText(panel, -1, ' ')) button2 = wx.Button(panel, -1, 'delete') wx.EVT_BUTTON(frame, button2.GetId(), self.delete_thost) b.Add(button2, 0) b.Add(wx.StaticText(panel, -1, ' ')) button3 = wx.Button(panel, -1, 'save as...') wx.EVT_BUTTON(frame, button3.GetId(), self.save_thost) b.Add(button3, 0) gridSizer.Add(wx.StaticText(panel, -1, '')) gridSizer.Add(b, 0, wx.ALIGN_CENTER) gridSizer.Add(wx.StaticText(panel, -1, '')) gridSizer.Add(wx.StaticText(panel, -1, '')) gridSizer.Add(wx.StaticText(panel, -1, 'single tracker url:'), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) self.annCtl = wx.TextCtrl(panel, -1, 'http://my.tracker:6969/announce') gridSizer.Add(self.annCtl, 0, wx.EXPAND) a = wx.FlexGridSizer(cols=1, vgap=3) a.Add(wx.StaticText(panel, -1, 'tracker list:'), 0, wx.ALIGN_RIGHT) a.Add(wx.StaticText(panel, -1, '')) abutton = wx.Button(panel, -1, 'copy\nannounces\nfrom\ntorrent', size=(70, 70)) wx.EVT_BUTTON(frame, abutton.GetId(), self.announcecopy) a.Add(abutton, -1, wx.ALIGN_CENTER) a.Add(wx.StaticText(panel, -1, DROP_HERE), -1, wx.ALIGN_CENTER) gridSizer.Add(a, -1, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) self.annListCtl = wx.TextCtrl( panel, -1, '\n', wx.Point(-1, -1), (300, 120), wx.TE_MULTILINE | wx.HSCROLL | wx.TE_DONTWRAP) gridSizer.Add(self.annListCtl, -1, wx.EXPAND) gridSizer.Add(wx.StaticText(panel, -1, '')) exptext = wx.StaticText( panel, -1, 'a list of tracker urls separated ' 'by commas or whitespace\nand on several ' 'lines -trackers on the same line will be\n' 'tried randomly, and all the trackers on one ' 'line\nwill be tried before the trackers on ' 'the next line.') exptext.SetFont(wx.Font(6, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False)) gridSizer.Add(exptext, -1, wx.ALIGN_CENTER) self.refresh_thostlist() self._set_thost() if sys.platform == 'win32': self.dropTargetPtr.DragAcceptFiles(True) wx.EVT_DROP_FILES(self.dropTargetPtr, self.selectdrop) self.groupSizer1Box.DragAcceptFiles(True) wx.EVT_DROP_FILES(self.groupSizer1Box, self.selectdrop) abutton.DragAcceptFiles(True) wx.EVT_DROP_FILES(abutton, self.announcedrop) self.annCtl.DragAcceptFiles(True) wx.EVT_DROP_FILES(self.annCtl, self.announcedrop) self.annListCtl.DragAcceptFiles(True) wx.EVT_DROP_FILES(self.annListCtl, self.announcedrop) gridSizer.Add(wx.StaticText(panel, -1, '')) gridSizer.Add(wx.StaticText(panel, -1, '')) gridSizer.Add(wx.StaticText(panel, -1, 'piece size:'), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) self.piece_length = wx.Choice(panel, -1, choices=[ 'automatic', '2MiB', '1MiB', '512KiB', '256KiB', '128KiB', '64KiB', '32KiB' ]) self.piece_length_list = [0, 21, 20, 19, 18, 17, 16, 15] self.piece_length.SetSelection(0) gridSizer.Add(self.piece_length) gridSizer.Add(wx.StaticText(panel, -1, 'comment:'), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) self.commentCtl = wx.TextCtrl(panel, -1, '') gridSizer.Add(self.commentCtl, 0, wx.EXPAND) gridSizer.Add(wx.StaticText(panel, -1, '')) gridSizer.Add(wx.StaticText(panel, -1, '')) b1 = wx.Button(panel, -1, 'Cancel', size=(-1, 30)) wx.EVT_BUTTON(frame, b1.GetId(), self.cancel) gridSizer.Add(b1, 0, wx.EXPAND) b2 = wx.Button(panel, -1, 'MAKE TORRENT', size=(-1, 30)) wx.EVT_BUTTON(frame, b2.GetId(), self.complete) gridSizer.Add(b2, 0, wx.EXPAND) gridSizer.AddGrowableCol(1) colSizer.Add(gridSizer, -1, wx.ALIGN_CENTER_VERTICAL) fullSizer.Add(colSizer) border = wx.BoxSizer(wx.HORIZONTAL) border.Add(fullSizer, 1, wx.EXPAND | wx.ALL, 15) panel.SetSizer(border) panel.SetAutoLayout(True) border.Fit(panel) frame.Fit() frame.Show(True) super(AdvancedDownloadInfo, self).__init__(frame) wx.EVT_CLOSE(frame, self._close)
def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ factory = self.factory # Establish the range of the slider: low_name = high_name = '' low, high = factory.low, factory.high if high <= low: low = high = None handler = self.object.trait(self.name).handler if isinstance(handler, BaseRange): low_name, high_name = handler._low_name, handler._high_name if low_name == '': low = handler._low if high_name == '': high = handler._high elif isinstance(handler, BaseEnum): if handler.name == '': self.mapping = handler.values else: self.sync_value(handler.name, 'mapping', 'from') low, high = 0, self.high # Create the control: self.control = control = wx.Window(parent, -1, size=wx.Size(50, 18), style=wx.FULL_REPAINT_ON_RESIZE | wx.TAB_TRAVERSAL) # Set up the painting event handlers: wx.EVT_ERASE_BACKGROUND(control, self._erase_background) wx.EVT_PAINT(control, self._on_paint) wx.EVT_SET_FOCUS(control, self._set_focus) # Set up mouse event handlers: wx.EVT_LEAVE_WINDOW(control, self._leave_window) wx.EVT_ENTER_WINDOW(control, self._enter_window) wx.EVT_LEFT_DOWN(control, self._left_down) wx.EVT_LEFT_UP(control, self._left_up) wx.EVT_MOTION(control, self._motion) wx.EVT_MOUSEWHEEL(control, self._mouse_wheel) # Set up the control resize handler: wx.EVT_SIZE(control, self._resize) # Set the tooltip: self._can_set_tooltip = (not self.set_tooltip()) # Save the values we calculated: self.set(low=low, high=high) self.sync_value(low_name, 'low', 'from') self.sync_value(high_name, 'high', 'from') # Force a reset (in case low = high = None, which won't cause a # notification to fire): self._reset_scrubber()
def __init__(self, config, calls): self.config = config self.calls = calls self.cancelflag = threading.Event() self.switchlock = threading.Lock() self.working = False self.queue = [] wx.InitAllImageHandlers() self.thostselection = self.calls['getCurrentTHost']() self.thostselectnum = 0 self.choices = None self.choices1 = None self.announce = '' self.announce_list = None self.windowStyle = wx.SYSTEM_MENU | wx.CAPTION | wx.MINIMIZE_BOX if self.config['stayontop']: self.windowStyle |= wx.STAY_ON_TOP frame = wx.Frame(None, -1, 'T-Make', size=wx.Size(-1, -1), style=self.windowStyle) self.frame = frame panel = wx.Panel(frame, -1) mainSizer = wx.BoxSizer(wx.VERTICAL) groupSizer = wx.FlexGridSizer(cols=1, vgap=0, hgap=0) # self.dropTarget = self.calls['newDropTarget']((200, 200)) self.dropTarget = self.calls['newDropTarget']() self.dropTargetPtr = wx.StaticBitmap(panel, -1, self.dropTarget) self.calls['setDropTargetRefresh'](self.dropTargetPtr.Refresh) self.dropTargetWidth = self.dropTarget.GetWidth() wx.EVT_LEFT_DOWN(self.dropTargetPtr, self.dropTargetClick) wx.EVT_ENTER_WINDOW(self.dropTargetPtr, self.calls['dropTargetHovered']) wx.EVT_LEAVE_WINDOW(self.dropTargetPtr, self.calls['dropTargetUnhovered']) groupSizer.Add(self.dropTargetPtr, 0, wx.ALIGN_CENTER) lowerSizer1 = wx.GridSizer(cols=6) dirlink = wx.StaticText(panel, -1, 'dir') dirlink.SetFont(wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.NORMAL, True)) dirlink.SetForegroundColour('blue') wx.EVT_LEFT_UP(dirlink, self.selectdir) lowerSizer1.Add(dirlink, -1, wx.ALIGN_LEFT) lowerSizer1.Add(wx.StaticText(panel, -1, ''), -1, wx.ALIGN_CENTER) lowerSizer1.Add(wx.StaticText(panel, -1, ''), -1, wx.ALIGN_CENTER) lowerSizer1.Add(wx.StaticText(panel, -1, ''), -1, wx.ALIGN_CENTER) lowerSizer1.Add(wx.StaticText(panel, -1, ''), -1, wx.ALIGN_CENTER) filelink = wx.StaticText(panel, -1, 'file') filelink.SetFont(wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.NORMAL, True)) filelink.SetForegroundColour('blue') wx.EVT_LEFT_UP(filelink, self.selectfile) lowerSizer1.Add(filelink, -1, wx.ALIGN_RIGHT) groupSizer.Add(lowerSizer1, -1, wx.ALIGN_CENTER) self.gauge = wx.Gauge(panel, -1, range=1000, style=wx.GA_HORIZONTAL, size=(-1, 15)) groupSizer.Add(self.gauge, 0, wx.EXPAND) self.statustext = wx.StaticText(panel, -1, 'ready', style=wx.ALIGN_CENTER | wx.ST_NO_AUTORESIZE) self.statustext.SetFont( wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.BOLD, False)) groupSizer.Add(self.statustext, -1, wx.EXPAND) self.choices = wx.Choice(panel, -1, (-1, -1), (self.dropTargetWidth, -1), choices=[]) self.choices.SetFont( wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False)) wx.EVT_CHOICE(self.choices, -1, self.set_thost) groupSizer.Add(self.choices, 0, wx.EXPAND) cancellink = wx.StaticText(panel, -1, 'cancel') cancellink.SetFont(wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.NORMAL, True)) cancellink.SetForegroundColour('red') wx.EVT_LEFT_UP(cancellink, self.cancel) groupSizer.Add(cancellink, -1, wx.ALIGN_CENTER) advlink = wx.StaticText(panel, -1, 'advanced') advlink.SetFont(wx.Font(7, wx.DEFAULT, wx.NORMAL, wx.NORMAL, True)) advlink.SetForegroundColour('blue') wx.EVT_LEFT_UP(advlink, self.calls['switchToAdvanced']) groupSizer.Add(advlink, -1, wx.ALIGN_CENTER) mainSizer.Add(groupSizer, 0, wx.ALIGN_CENTER) self.refresh_thostlist() self._set_thost() if sys.platform == 'win32': self.dropTargetPtr.DragAcceptFiles(True) wx.EVT_DROP_FILES(self.dropTargetPtr, self.selectdrop) # border = wxBoxSizer(wxHORIZONTAL) # border.Add(mainSizer, 1, wxEXPAND | wxALL, 0) panel.SetSizer(mainSizer) panel.SetAutoLayout(True) # border.Fit(panel) mainSizer.Fit(panel) frame.Fit() frame.Show(True) super(BasicDownloadInfo, self).__init__(frame) wx.EVT_CLOSE(frame, self._close)
def __init__(self, master, gradient_table, color_space, width, height): """Initialize a function control widget on tkframe master. Parameters: ----------- master: The master widget. Note that this widget *must* have the methods specified in the `AbstractGradEditorWidget` interface. on_table_changed: Callback function taking a bool argument of meaning 'FinalUpdate'. FinalUpdate is true if a control point is dropped, created or removed and false if the update is due to a control point currently beeing dragged (but not yet dropped) color_space: String which specifies the channels painted on this control. May be any combination of h,s,v,r,g,b,a in which each channel occurs only once. set_status_text: a callback used to set the status text when using the editor. """ self.text_map = {'r': 'RED', 'g': 'GREEN', 'b': 'BLUE', 'h': 'HUE', 's': 'SATURATION', 'v': 'VALUE', 'a': 'ALPHA'} self.master = master self.table = gradient_table self.gradient_table = gradient_table self.width = width self.height = height wx.Panel.__init__(self, master, size=wx.Size(width, height), name="RGBHSVA Editor") # You can pass style=wx.RAISED_BORDER into wx.Panel() to make a border, but.... # then a few pixels on each side are chopped off... #self.SetBackgroundColour(wx.Colour(255,0,0)) self.channels = [] # add the channels for c in color_space: if c == 'r': self.channels += [Channel(self, "r", (255,0,0), 0, 'rgb' )] elif c == 'g': self.channels += [Channel(self, "g", (0,255,0), 1, 'rgb' )] elif c == 'b': self.channels += [Channel(self, "b", (0,0,255), 2, 'rgb' )] elif c == 'h': self.channels += [Channel(self, "h", (255,0,0), 0, 'hsv' )] elif c == 's': self.channels += [Channel(self, "s", (0,255,0), 1, 'hsv' )] elif c == 'v': self.channels += [Channel(self, "v", (0,0,255), 2, 'hsv' )] elif c == 'a': self.channels += [Channel(self, "a", (0,0,0), 3, 'hsv' )] # generate a list of channels on which markers should # be bound if moved on the current channel. since we interpolate # the colors in hsv space, changing the r, g or b coordinates # explicitely means that h, s and v all have to be fixed. self.active_channels_string = "" for channel in self.channels: self.active_channels_string += channel.name if ( ( 'r' in color_space ) or ( 'g' in color_space ) or ( 'b' in color_space ) ): for c in "hsv": if ( not ( c in self.active_channels_string ) ): self.active_channels_string += c if ( color_space == 'a' ): # alpha channels actually independent of all other channels. self.active_channels_string = 'a' self.update() wx.EVT_LEFT_DOWN(self, self.on_left_button_down) wx.EVT_LEFT_UP(self, self.on_left_button_up) wx.EVT_RIGHT_DOWN(self, self.on_right_button_down) wx.EVT_RIGHT_UP(self, self.on_right_button_up) wx.EVT_MOTION(self, self.on_mouse_move) wx.EVT_PAINT(self, self.on_paint) wx.EVT_LEAVE_WINDOW(self, self.on_leave_window) # need to set to "None" initially or event handlers get confused. self.cur_drag = None #<- [channel,control_point] while something is dragged.