Search Results

Search found 203 results on 9 pages for 'wxpython'.

Page 3/9 | < Previous Page | 1 2 3 4 5 6 7 8 9  | Next Page >

  • wxPython - Save Items in ListCtrl

    - by dpswt
    Hello everyone. My question is if we can save the items on ListCtrl so everytime someone opens the application, the items are there and if the user removes it, it also removes from the configuration. I know that I can use wx.Config and I'm trying to accomplish using that but I don't know how to read it in a way to accomplish what I want. So what I would like to know is a proper way to write/read the wx.Config in a way that everytime someone opens the application, the items from ListCtrl are there. Thanks in advance.

    Read the article

  • wxPython: Change a buttons text in a wx.FileDialog

    - by Sascha
    Hello I have a wx.FileDialog (with the wx.FD_OPEN flag) & I would like to know if I can (& how) I could change the button in the bottom right of the FileDialog from "Open" to "Create" or "Delete", etc. What I am doing is I have a button with the text "Delete Portfolio", when pressed it opens a FileDialog & allows the user to select a portfolio file(.db) to delete. So instead of the File Dialog's bottom right confirm button displaying "Open" I would like to be able to change the text to "Confirm" or "Delete" or whatever. Is this possible, its a rather superficial thing to do, but if the button says open when the user wants to select a file to delete, it can be a little confusing even if the title of the dialog says "please select a file to delete"

    Read the article

  • ListCtrl - wxPython / Python

    - by Francisco Aleixo
    Hello everyone. My question is if we can assign/bind some value to a certain item and hide that value(or if we can do the same thing in another way). Example: Lets say the columns on ListCtrl are "Name" and "Description": self.lc = wx.ListCtrl(self, -1, style=wx.LC_REPORT) self.lc.InsertColumn(0, 'Name') self.lc.InsertColumn(1, 'Description') And when I add a item I want them to show the Name parameter and the description: num_items = self.lc.GetItemCount() self.lc.InsertStringItem(num_items, "Randomname") self.lc.SetStringItem(num_items, 1, "Some description here") Now what I want to do is basically assign something to that item that is not shown so I can access later on the app. So I would like to add something that is not shown on the app but is on the item value like: hiddendescription = "Somerandomthing" Still didn't undestand? Well lets say I add a button to add a item with some other TextCtrls to set the parameters and the TextCtrls parameters are: "Name" "Description" "Hiddendescription" So then the user fills this textctrls out and clicks the button to create the item, and I basically want only to show the Name and Description and hide the "HiddenDescription" but to do it so I can use it later. Sorry for explaining more than 1 time on this post but I want to make sure you understand what I pretend to do.

    Read the article

  • wxpython - Nested Notebooks

    - by madtowneast
    I have been trying to make my nested notebooks a little bit more appealing code wise. At the moment, I got this #!/usr/bin/env python import os import sys import datetime import numpy as np from readmonifile import MonitorFile from sortmonifile import sort import wx class NestedPanelOne(wx.Panel): #---------------------------------------------------------------------- # First notebook that creates the tab to select the component number #---------------------------------------------------------------------- def __init__(self, parent, label, data): wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY) sizer = wx.BoxSizer(wx.VERTICAL) #Loop creating the tabs according to the component name nestedNotebook = wx.Notebook(self, wx.ID_ANY) for slabel in sorted(data[label].keys()): tab = NestedPanelTwo(nestedNotebook, label, slabel, data) nestedNotebook.AddPage(tab,slabel) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(nestedNotebook, 1, wx.ALL|wx.EXPAND, 5) self.SetSizer(sizer) class NestedPanelTwo(wx.Panel): #------------------------------------------------------------------------------ # Second notebook that creates the tab to select the main monitoring variables #------------------------------------------------------------------------------ def __init__(self, parent, label, slabel, data): wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY) sizer = wx.BoxSizer(wx.VERTICAL) nestedNotebook = wx.Notebook(self, wx.ID_ANY) for sslabel in sorted(data[label][slabel][data[label][slabel].keys()[0]].keys()): tab = NestedPanelThree(nestedNotebook, label, slabel, sslabel, data) nestedNotebook.AddPage(tab, sslabel) sizer.Add(nestedNotebook, 1, wx.ALL|wx.EXPAND, 5) self.SetSizer(sizer) class NestedPanelThree(wx.Panel): #------------------------------------------------------------------------------- # Third notebook that creates checkboxes to select the monitoring sub-variables #------------------------------------------------------------------------------- def __init__(self, parent, label, slabel, sslabel, data): wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY) labels=[] chbox =[] chboxdict={} for ssslabel in sorted(data[label][slabel][data[label][slabel].keys()[0]][sslabel].keys()): labels.append(ssslabel) for item in list(set(labels)): cb = wx.CheckBox(self, -1, item) chbox.append(cb) chboxdict[item]=cb gridSizer = wx.GridSizer(np.shape(list(set(labels)))[0],3, 5, 5) gridSizer.AddMany(chbox) self.SetSizer(gridSizer) ######################################################################## class NestedNotebookDemo(wx.Notebook): #--------------------------------------------------------------------------------- # Main notebook creating tabs for the monitored components #--------------------------------------------------------------------------------- def __init__(self, parent, data): wx.Notebook.__init__(self, parent, id=wx.ID_ANY, style= wx.BK_DEFAULT ) for label in sorted(data.keys()): print label tab = NestedPanelOne(self,label, data) self.AddPage(tab, label) ######################################################################## class DemoFrame(wx.Frame): #---------------------------------------------------------------------- # Putting it all together #---------------------------------------------------------------------- def __init__(self,data): wx.Frame.__init__(self, None, wx.ID_ANY, "pDAQ monitoring plotting tool", size=(800,400) ) panel = wx.Panel(self) notebook = NestedNotebookDemo(panel, data) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(notebook, 1, wx.ALL|wx.EXPAND, 5) panel.SetSizer(sizer) self.Layout() #Menu Bar to be added later ''' menubar = wx.MenuBar() file = wx.Menu() file.Append(1, '&Quit', 'Exit Tool') menubar.Append(file, '&File') self.SetMenuBar(menubar) self.Bind(wx.EVT_MENU, self.OnClose, id=1) ''' self.Show() #---------------------------------------------------------------------- if __name__ == "__main__": if len(sys.argv) == 1: raise SystemExit("Please specify a file to process") for f in sys.argv[1:]: data=sort.sorting(f) print data['stringHub'].keys() print data.keys() print data[data.keys()[0]].keys() print 'test' app = wx.PySimpleApp() frame = DemoFrame(data) app.MainLoop() print 'testend' and I would like to reduce this whole mess into something that only has three nested for loops, so something like for label in sorted(data.keys()): self.SubNoteBooks[label] = wx.Notebook(self.Notebook, wx.ID_ANY) self.Notebook.AddPage(self.SubNoteBooks[label], label) for slabel in sorted(data[label].keys()): self.SubNoteBooks[label][slabel] = wx.Notebook(self, wx.ID_ANY) self.SubNoteBooks[label].AddPage(self.SubNoteBooks[label][slabel], slabel) for sslabel in sorted(data[label][slabel][data[label][slabel].keys()[0]].keys()): self.SubNoteBooks[label][slabel][sslabel] = wx.Notebook(self.Notebook, wx.ID_ANY) self.Notebook.AddPage(self.SubNoteBooks[label][slabel][sslabel], sslabel) I have been trying to fiddle this around but the problem seems to be the line self.SubNoteBooks[label][slabel] = wx.Notebook(self, wx.ID_ANY) I get the error: Traceback (most recent call last): File "./reducelinenumbers.py", line 162, in <module> frame = DemoFrame(data) File "./reducelinenumbers.py", line 126, in __init__ self.SubNoteBooks[label][slabel] = wx.Notebook(self, wx.ID_ANY) TypeError: 'Notebook' object does not support item assignment I understand why notebook is being type raises a TypeError here. Is there a way around this? Thanks a bunch in advance.

    Read the article

  • wxPython - ListCrtl and SQLite3

    - by Dunwitch
    I'm trying to get a SQLite3 DB to populate a wx.ListCrtl. I can get it to print to stdout/stderr without any problem. I just can't seem to figure out how to display the data in the DataWindow/DataList? I'm sure I've made some code mistakes, so any help is appreciated. Main.py import wx import wx.lib.mixins.listctrl as listmix from database import * import sys class DataWindow(wx.Frame): def __init__(self, parent = None): wx.Frame.__init__(self, parent, -1, 'DataList', size=(640,480)) self.win = DataList(self) self.Center() self.Show(True) class DataList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin): def __init__(self, parent = DataWindow): wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES) #building the columns self.InsertColumn(0, "Location") self.InsertColumn(1, "Address") self.InsertColumn(2, "Subnet") self.InsertColumn(3, "Gateway") self.SetColumnWidth(0, 100) self.SetColumnWidth(1, 150) self.SetColumnWidth(2, 150) self.SetColumnWidth(3, 150) class MainWindow(wx.Frame): def __init__(self, parent = None, id = -1, title = "MainWindow"): wx.Frame.__init__(self, parent, id, title, size = (800,600), style = wx.DEFAULT_FRAME_STYLE ^ (wx.RESIZE_BORDER)) # StatusBar self.CreateStatusBar() # Filemenu filemenu = wx.Menu() # Filemenu - About menuitem = filemenu.Append(-1, "&About", "Information about this application") self.Bind(wx.EVT_MENU, self.onAbout, menuitem) #Filemenu - Data menuitem = filemenu.Append(-1, "&Data", "Get data") self.Bind(wx.EVT_MENU, self.onData, menuitem) # Filemenu - Seperator filemenu.AppendSeparator() #Filemenu - Exit menuitem = filemenu.Append(-1, "&Exit", "Exit the application") self.Bind(wx.EVT_MENU, self.onExit, menuitem) # Menubar menubar = wx.MenuBar() menubar.Append(filemenu, "&File") self.SetMenuBar(menubar) # Show self.Show(True) self.Center() def onAbout(self, event): pass def onData(self, event): DataWindow(self) callDb = Database() sql = "SELECT rowid, address, subnet, gateway FROM pod1" records = callDb.select(sql) for v in records: print "How do I get the records on the DataList?" #print "%s%s%s" % (v[1],v[2],v[3]) #for v in records: #DataList.InsertStringItem("%s") % (v[0], v[1], v[2]) def onExit(self, event): self.Close() self.Destroy() def onSave(self, event): pass if __name__ == '__main__': app = wx.App() frame = MainWindow(None, -1) frame.Show() app.MainLoop() database.py import os import sqlite3 class Database(object): def __init__(self, db_file="data/data.sqlite"): database_allready_exists = os.path.exists(db_file) self.db = sqlite3.connect(db_file) if not database_allready_exists: self.setupDefaultData() def select(self,sql): cursor = self.db.cursor() cursor.execute(sql) records = cursor.fetchall() cursor.close return records def insert(self,sql): newID = 0 cursor = self.db.cursor() cursor.execute(sql) newID = cursor.lastrowid self.db.commit() cursor.close() return newID def save(self,sql): cursor = self.db.cursor() cursor.execute(sql) self.db.commit() cursor.close() def setupDefaultData(self): pass

    Read the article

  • wxpython: Updating a dict or other appropriate data type from wx.lib.sheet.CSheet object

    - by bvmou
    If I have a notebook with three spreadsheet widgets, what is the best way to have changes to the spreadsheet update a dictionary (or maybe an sqlite file?). Do all wx grid objects come with a built in dictionary related to the SetNumberRows and SetNumberCols? Basically I am looking for guidance on how to work with the user-input data from a spreadsheet widget, as in this example adapted from the tutorial on python.org: class ExSheet(wx.lib.sheet.CSheet): def __init__(self, parent): sheet.CSheet.__init__(self, parent) self.SetLabelBackgroundColour('#CCFF66') self.SetNumberRows(50) self.SetNumberCols(50) class Notebook(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title) nb = wx.Notebook(self, -1, style=wx.NB_BOTTOM) self.sheet1 = ExSheet(nb) self.sheet2 = ExSheet(nb) self.sheet3 = ExSheet(nb) nb.AddPage(self.sheet1, "Sheet1") nb.AddPage(self.sheet2, "Sheet2") nb.AddPage(self.sheet3, "Sheet3") self.sheet1.SetFocus() self.StatusBar()

    Read the article

  • WxPython multiple grid instances

    - by randomPythonHacker
    Does anybody know how I can get multiple instances of the same grid to display on one frame? Whenever I create more than 1 instance of the same object, the display of the original grid widget completely collapses and I'm left unable to do anything with it. For reference, here's the code: import wx import wx.grid as gridlib class levelGrid(gridlib.Grid): def __init__(self, parent, rows, columns): gridlib.Grid.__init__(self, parent, -1) self.moveTo = None self.CreateGrid(rows, columns) self.SetDefaultColSize(32) self.SetDefaultRowSize(32) self.SetColLabelSize(0) self.SetRowLabelSize(0) self.SetDefaultCellBackgroundColour(wx.BLACK) self.EnableDragGridSize(False) class mainFrame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(768, 576)) editor = levelGrid(self, 25, 25) panel1 = wx.Panel(editor, -1) #vbox = wx.BoxSizer(wx.VERTICAL) #vbox.Add(editor, 1, wx.EXPAND | wx.ALL, 5) #selector = levelGrid(self, 1, 25) #vbox.Add(selector, 1, wx.EXPAND |wx.BOTTOM, 5) self.Centre() self.Show(True) app = wx.App() mainFrame(None, -1, "SLAE") app.MainLoop()

    Read the article

  • wxpython PyGridTableBase

    - by nozkan
    Hi, I want to use editable choice editor with PyGridTableBase. When I edit a cell it is crashing What is error in my code? My python code: import wx import wx.grid as gridlib class MyTableBase(gridlib.PyGridTableBase): def __init__(self): gridlib.PyGridTableBase.__init__(self) self.data = {0:["value 1", "value 2"], 1:["value 3", "value 4", "value 5"]} self.column_labels = [unicode(u"Label 1"), unicode(u"Label 2"), unicode(u"Label 3")] self._rows = self.GetNumberRows() self._cols = self.GetNumberCols() def GetColLabelValue(self, col): return self.column_labels[col] def GetNumberRows(self): return len(self.data.keys()) def GetNumberCols(self): return len(self.column_labels) def GetValue(self, row, col): try: if col > self.GetNumberCols(): raise IndexError return self.data[row][col] except IndexError: return None def IsEmptyCell(self, row, col): if self.data[row][col] is not None: return True else: return False def GetAttr(self, row, col, kind): attr = gridlib.GridCellAttr() editor = gridlib.GridCellChoiceEditor(["xxx", "yyy", "zzz"], allowOthers = True) attr.SetEditor(editor) attr.IncRef() return attr class MyDataGrid(gridlib.Grid): def __init__(self, parent): gridlib.Grid.__init__(self, parent, wx.NewId()) self.base_table = MyTableBase() self.SetTable(self.base_table) if __name__ == '__main__': app = wx.App(redirect = False) frame = wx.Frame(None, wx.NewId(), title = u"Test") grid_ = MyDataGrid(frame) frame.Show() app.MainLoop()

    Read the article

  • Best canvas for drawing in wxPython?

    - by Pablo Rodriguez
    I have to draw a graph of elements composing a topological model of a physical network. There would be nodes and arches, and the latter could be unidirectional or bidirectional. I would like to capture the clicking events for the nodes and the arches (to select the element and show its properties somewhere), and the dragging events for the nodes (to move them around) and arches (to connect or disconnect elements). I've done some research and I've narrowed the alternatives down to OGL (Object Graphics Library) and FloatCanvas. I would not like to go down to the DrawingContext, but it is not discarded if necessary. Which canvas option would you choose?

    Read the article

  • Wxpython cut copy paste and openfiledialog...

    - by Marius
    i have a web browser made in python with menu. in one menu i have cut copy paste but no functionality and i need to make them work. i need an example of class oncopy.(event menu) Open file i manage to work like this .takes file and print on screen the link to that file but how can make open dialog to open a file at least one type of file?

    Read the article

  • wxPython - wx.ChildFrame

    - by Dunwitch
    I'm sure this is simple, but I can't seem to find the answer. While using wx.MDIParentFrame, I open a new window with wx.MDIChildFrame. There is static text on the ParentFrame, and once the ChildFrame opens the text gets erased from the ParentFrame? import wx class Frame(wx.MDIParentFrame): def __init__(self): wx.MDIParentFrame.__init__(self, None, -1, "Main Window", size=(800,600), style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_NO_WINDOW_MENU) menu = wx.Menu() menu.Append(100, "&New Window") menu.Append(101, "E&xit") menubar = wx.MenuBar() menubar.Append(menu, "&File") self.SetMenuBar(menubar) self.Bind(wx.EVT_MENU, self.OnNewWindow, id=100) self.Bind(wx.EVT_MENU, self.OnExit, id=101) self.Center() background_text = wx.StaticText(self, id=-1, label="This is background text", pos = (20, 250)) def OnExit(self, evt): self.Close(True) self.Destroy() def OnNewWindow(self, evt): win = wx.MDIChildFrame(self, -1, "Child Window", size = (300, 300), style=wx.DEFAULT_FRAME_STYLE ^ (wx.MAXIMIZE_BOX | wx.RESIZE_BORDER)) win.SetBackgroundColour("#BB00e0") win.Show(True) if __name__ == '__main__': app = wx.PySimpleApp() frame = Frame() frame.Show() app.MainLoop()

    Read the article

  • wxPython - How can I display a html formatted string in wx.RichTextCtrl

    - by wxpydon
    Hello, I'm trying to display some string (html formatted) in a Richtext Ctrl. In my code I tried to use it this way (self.txtmain is the RichTextCtrl): out = StringIO() htmlhandler = rt.RichTextHTMLHandler() buffer = self.txtmain.GetBuffer() buffer.AddHandler(htmlhandler) out.write(string) out.seek(0) htmlhandler.LoadStream(buffer, out) self.txtmain.Refresh() No errors are issued, but the RichTextCtrl windows is not updated. What am I missing here?

    Read the article

  • wxPython: MainLoop() seems to hang

    - by BandGap
    Hi all, my problem stems from the use of wxApp as far as I can tell. Inside a litte subroutine I call a wx.MessageDialog to ask for a yes or no. I retrieve the answer an process some stuff acordingly. My example code below actually works (though it might be ugly) except that the Dialog box stays open after hitting one of the buttons... import wx from os import path def HasFile(filename): if path.isfile(filename ): app = wx.App() dial = wx.MessageDialog(None, 'Die Datei "'+filename+'" wurde gefunden.\nSoll sie eingelesen werden?', 'Bitte antworten', wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION) result = dial.ShowModal() dial.EndModal(retCode=0) dial.Destroy() app.MainLoop() return result == wx.ID_YES else: return False So while the rest of the program does whatever is expected, the box just sits there. It also seems like my calls to matplotlib later on are producing errors (a Tkinter error to be precise), maybe because of the wx stuff? Edit: I tried to end the app with a call to app.Destroy(). This doesn't change the fact that the box is still there. When I issue a app.IsActive() afterwards the whole program exits (almost like a sys.exit())! How come? Edit 2: Adding a wxApp like this isn't a good idea since the other scripts get affected as well. Subsequent plotting commands don't get displayed and I don't know how to fix this. Thus I decided to remove the DialogBox alltogether.

    Read the article

  • Get text when enter is pressed in a text box in wxPython

    - by Sam
    I have a (single line) TextCtrl. The user types data into this. When they press enter, the contents of the box need to be extracted so they can be processed. I can't figure out how to catch enter being pressed. According to the docs, with the style wx.TE_PROCESS_ENTER set on my TextCtrl, it should generate a wx.EVT_COMMAND_TEXT_ENTER event when enter is pressed in the box, which I could then catch. However, wx.EVT_COMMAND_TEXT_ENTER seems not to exist (I get "module has no attribute EVT_COMMAND_TEXT_ENTER), so I'm a bit stuck. Googling just gets a couple of hits of people complaining wx.EVT_COMMAND_TEXT_ENTER doesn't work, so I guess I need another way of doing it.

    Read the article

  • wxpython : button covers all in the frame

    - by Prakash
    Below is my code: #!/usr/bin/python # -*- coding: utf-8 -*- import wx class Example(wx.Frame): def __init__(self): #super(Example, self).__init__(parent, title=title, size=(300, 200)) wx.Frame.__init__(self, None, wx.ID_ANY, 'wxButton', pos=(300, 150), size=(320, 250)) self.button1 = wx.Button(self, id=-1, label='Button1', pos=(8, 8), size=(10, 20)) self.button1.Bind(wx.EVT_BUTTON, self.button1Click) self.Centre() self.Show() def button1Click(self,event): #self.button1.Hide() self.SetTitle("Button1 clicked") if __name__ == '__main__': app = wx.App() Example() app.MainLoop() Actually I am expecting the button1 on the frame to have a look like a button - a bit raised and be placed in center of frame - but it is just expanding to the full frame. Also text Button1 looks like a text which does not has a button look like feeling? What wrong am I doing?

    Read the article

  • wxpython Prevent Ctrl+Enter from changing the focus

    - by RSabet
    I have two wxListCtrl and want to process the Ctrl+Enter keyboard event without letting wx change the focus to the other ListCtrl. I have event handlers for wx.EVT_KEY_DOWN, wx.EVT_KEY_UP, wx.EVT_CHAR and KillFocus, but KillFocus is always called first, then the focus changes and the the keyboard handlers are called for the wrong ListCtrl. Is there a way to prevent wx from changing the focus, when Ctrl+Enter is pressed ?

    Read the article

  • How to change the OSX menubar in wxPython without any opened window?

    - by gyim
    I am writing a wxPython application that remains open after closing all of its windows - so you can still drag & drop new files onto the OSX dock icon (I do this with myApp.SetExitOnFrameDelete(False)). Unfortunately if I close all the windows, the OSX menubar will only contain a "Help" menu. I would like to add at least a File/Open menu item, or just keep the menubar of the main window. Is this somehow possible in wxPython? In fact, I would be happy with a non-wxPython hack as well (for example, setting the menu in pyobjc). wxPython development in OSX is such a hack anyway ;)

    Read the article

  • how to set wxPython main frame bottom right on screen?

    - by Hitesh Chavda
    For better description, +-----------------------+ | Desktop (screen) | | | | | | +----------+ | | | wxPython | | | | App. | | | | | | | | | | | +----------+ | +-----------------------+ Look at WxPython App., which is align to the bottom right of screen. How to I position my main frame because screen width is different on each pc? For Better Understanding, I want to pop-up small window like Digsby and FeedNotifier use! i think both use python!!

    Read the article

  • Good looking programs that use wxPython for their UI

    - by ChrisC
    I need inspiration and motivation so I'm trying to find examples of different programs that have interesting and attractive UI's created free using wxPython. My searches have been slow to find results. I'm hoping you guys know of some of the best ones out there. btw, I've seen these: http://www.wxpython.org/screenshots.php and the list under "Applications Developed with wxPython" on the wxPython Wikipedia page. Update: only need Windows examples

    Read the article

  • Good looking programs that are built using wxPython for their UI

    - by ChrisC
    I need inspiration and motivation so I'm trying to find examples of different programs that have interesting and attractive UI's created free using wxPython. My searches have been slow to find results. I'm hoping you guys know of some of the best ones out there. btw, I've seen these: http://www.wxpython.org/screenshots.php and the list under "Applications Developed with wxPython" on the wxPython Wikipedia page. Update: only need Windows examples

    Read the article

  • Python - wxPython custom button -> unbound method __init__()? what?

    - by Wallter
    After looking at questions like this it doesn't make sense that my __init__(self, parrent, id) would be throwing a unbound error? help? main.py import wx from customButton import customButton from wxPython.wx import * class MyFrame(wx.Frame): def __init__(self, parent, ID, title): wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, wxSize(400, 400)) # Non-important code here... # This is the first declaration of the Button1 # This is also where the ERROR is thrown. # Omitting this line causes the window to execute # flawlessly. self.Button1 = customButton.__init__(self, parent, -1) # ... finishes in a basic wx.program style... customButton.py # I've included all of the code in the file # because have no idea where the bug/error happens import wx from wxPython.wx import * class Custom_Button(wx.PyControl): # The BMP's Over_bmp = None #wxEmptyBitmap(1,1,1) # When the mouse is over Norm_bmp = None #wxEmptyBitmap(1,1,1) # The normal BMP Push_bmp = None #wxEmptyBitmap(1,1,1) # The down BMP def __init__(self, parent, id, **kwargs): wx.PyControl.__init__(self,parent, id, **kwargs) # Set the BMP's to the ones given in the constructor #self.Over_bmp = wx.Bitmap(wx.Image(MOUSE_OVER_BMP, wx.BITMAP_TYPE_ANY).ConvertToBitmap()) #self.Norm_bmp = wx.Bitmap(wx.Image(NORM_BMP, wx.BITMAP_TYPE_ANY).ConvertToBitmap()) #self.Push_bmp = wx.Bitmap(wx.Image(PUSH_BMP, wx.BITMAP_TYPE_ANY).ConvertToBitmap()) #self.Pos_bmp = self.pos self.Bind(wx.EVT_LEFT_DOWN, self._onMouseDown) self.Bind(wx.EVT_LEFT_UP, self._onMouseUp) self.Bind(wx.EVT_LEAVE_WINDOW, self._onMouseLeave) self.Bind(wx.EVT_ENTER_WINDOW, self._onMouseEnter) self.Bind(wx.EVT_ERASE_BACKGROUND,self._onEraseBackground) self.Bind(wx.EVT_PAINT,self._onPaint) self._mouseIn = self._mouseDown = False def _onMouseEnter(self, event): self._mouseIn = True def _onMouseLeave(self, event): self._mouseIn = False def _onMouseDown(self, event): self._mouseDown = True def _onMouseUp(self, event): self._mouseDown = False self.sendButtonEvent() def sendButtonEvent(self): event = wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, self.GetId()) event.SetInt(0) event.SetEventObject(self) self.GetEventHandler().ProcessEvent(event) def _onEraseBackground(self,event): # reduce flicker pass def _onPaint(self, event): dc = wx.BufferedPaintDC(self) dc.SetFont(self.GetFont()) dc.SetBackground(wx.Brush(self.GetBackgroundColour())) dc.Clear() dc.DrawBitmap(self.Norm_bmp) # draw whatever you want to draw # draw glossy bitmaps e.g. dc.DrawBitmap if self._mouseIn: # If the Mouse is over the button dc.DrawBitmap(self, self.Mouse_over_bmp, self.Pos_bmp, useMask=False) if self._mouseDown: # If the Mouse clicks the button dc.DrawBitmap(self, self.Push_bmp, self.Pos_bmp, useMask=False)

    Read the article

  • how to disable window close button in OSX using wxpython?

    - by nur
    i am working on an application for osx using wxpython. I want to minimize window to dockbar when user clicks on the window close button so that it can be restored from the dockbar. How can i do that? Currently i am having problem restoring window because it gets destroyed when user clicks on the close button. how can i prevent that? Thanks in advance

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9  | Next Page >