wxpython interview questions
Top wxpython frequently asked interview questions
Okay, what is it, and why does it occur on Win2003 server, but not on WinXP.
It doesn't seem to affect my application at all, but I get this error message when I close the application. And it's annoying (as errors messages should be).
I am using pyOpenGl and wxPython to do the graphics stuff. Unfortunately, I'm a C# programmer that has taken over this Python app, and I had to learn Python to do it.
I can supply code and version numbers etc, but I'm still learning the technical stuff, so any help would be appreciated.
Python 2.5, wxPython and pyOpenGL
Source: (StackOverflow)
I'm developing a Python application using wxPython and freezing it using cxFreeze. All seems to be going fine apart from this following bit:
When I run the executable created by cxFreeze, a blank console window pops up. I don't want to show it. Is there any way I could hide it?
It doesn't seem to be documented on the cxFreeze site and Googling didn't turn up much apart from some similar sorta problems with Py2Exe.
Thanks.
Source: (StackOverflow)
I have a series of images that I want to create a video from. Ideally I could specify a frame duration for each frame but a fixed frame rate would be fine too. I'm doing this in wxPython, so I can render to a wxDC or I can save the images to files, like PNG. Is there a Python library that will allow me to create either a video (AVI, MPG, etc) or an animated GIF from these frames?
Edit: I've already tried PIL and it doesn't seem to work. Can someone correct me with this conclusion or suggest another toolkit? This link seems to backup my conclusion regarding PIL: http://www.somethinkodd.com/oddthinking/2005/12/06/python-imaging-library-pil-and-animated-gifs/
Source: (StackOverflow)
import wx
Traceback (most recent call last):
File "", line 1, in
import wx
File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\__init__.py", line 45, in
from wx._core import *
File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 4, in
import _core_
ImportError: DLL load failed: %1 is not a valid Win32 application
I have tried python2.6 and python2.7 with several wxpython versions,they all turned out to be like this.All the versions are win64 as well as my OS,please hep!
Source: (StackOverflow)
I'm looking for the same effect as alert()
in JavaScript.
I wrote a simple web-based interpreter this afternoon using Twisted.web. You basically submit a block of Python code through a form, and the client comes and grabs it and executes it. I want to be able to make a simple popup message, without having to re-write a whole bunch of boilerplate wxPython or TkInter code every time (since the code gets submitted through a form and then disappears).
I've tried tkMessageBox:
import tkMessageBox
tkMessageBox.showinfo(title="Greetings", message="Hello World!")
but this opens another window in the background with a tk icon. I don't want this. I was looking for some simple wxPython code but it always required setting up a class and entering an app loop etc. Is there no simple, catch-free way of making a message box in Python?
Source: (StackOverflow)
I am using python 2.6 on XP. I have just installed py2exe, and I can successfully create a simple hello.exe from a hello.py. However, when I try using py2exe on my real program, py2exe produces a few information messages but fails to generate anything in the dist folder.
My setup.py looks like this:
from distutils.core import setup
import py2exe
setup(console=['ServerManager.py'])
and the py2exe output looks like this:
python setup.py py2exe
running py2exe
creating C:\DevSource\Scripts\ServerManager\build
creating C:\DevSource\Scripts\ServerManager\build\bdist.win32
...
...
creating C:\DevSource\Scripts\ServerManager\dist
*** searching for required modules ***
*** parsing results ***
creating python loader for extension 'wx._misc_' (C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_misc_.pyd -> wx._misc_.pyd)
creating python loader for extension 'lxml.etree' (C:\Python26\lib\site-packages\lxml\etree.pyd -> lxml.etree.pyd)
...
...
creating python loader for extension 'bz2' (C:\Python26\DLLs\bz2.pyd -> bz2.pyd)
*** finding dlls needed ***
py2exe seems to have found all my imports (though I was a bit surprised to see win32 mentioned, as I am not explicitly importing it). Also, my program starts up quite happily with this command:
python ServerManager.py
Clearly I am doing something fundamentally wrong, but in the absence of any error messages from py2exe I have no idea what.
Source: (StackOverflow)
I have a little experience developing small command-line applications with Python. I want to move on to developing GUIs with Python. From the available GUI toolkits for Python, the ones I feel the most inclined to are wxPython and Tkinter; but I don't want to code all of the GUI by myself all of the time.
Are there any good GUI IDEs for any of these toolkits? It doesn't need to be free or open source.
Source: (StackOverflow)
I'm trying wxpython for the first time. I've wrote a GUI for a python program and when I run it, it produces some error in the GUI, but the GUI disappears very quickly, quickly enough for me to be unable to read the error info.
Is there any log that I can check for the error message? (I'm running Mac OS X) or any other way?
Thanks in advance for any help.
Update: Here's the code that's giving me the problem...
#!/usr/bin/python
import wx
class MyApp (wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(390, 350))
menubar = wx.MenuBar()
help = wx.Menu()
help.Append(ID_ABOUT, '&About')
self.Bind(wx.EVT_MENU, self.OnAboutBox, id=wx.ID_ABOUT)
menubar.Append(help, '&Help')
self.SetMenuBar(menubar)
self.Centre()
self.Show(True)
panel = wx.Panel(self, -1)
font = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT)
font.SetPointSize(9)
vbox = wx.BoxSizer(wx.VERTICAL)
hbox1 = wx.BoxSizer(wx.HORIZONTAL)
st1 = wx.StaticText(panel, -1, 'Class Name')
st1.SetFont(font)
hbox1.Add(st1, 0, wx.RIGHT, 8)
tc = wx.TextCtrl(panel, -1)
hbox1.Add(tc, 1)
vbox.Add(hbox1, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 10)
vbox.Add((-1, 10))
hbox2 = wx.BoxSizer(wx.HORIZONTAL)
st2 = wx.StaticText(panel, -1, 'Matching Classes')
st2.SetFont(font)
hbox2.Add(st2, 0)
vbox.Add(hbox2, 0, wx.LEFT | wx.TOP, 10)
vbox.Add((-1, 10))
hbox3 = wx.BoxSizer(wx.HORIZONTAL)
tc2 = wx.TextCtrl(panel, -1, style=wx.TE_MULTILINE)
hbox3.Add(tc2, 1, wx.EXPAND)
vbox.Add(hbox3, 1, wx.LEFT | wx.RIGHT | wx.EXPAND, 10)
vbox.Add((-1, 25))
hbox4 = wx.BoxSizer(wx.HORIZONTAL)
cb1 = wx.CheckBox(panel, -1, 'Case Sensitive')
cb1.SetFont(font)
hbox4.Add(cb1)
cb2 = wx.CheckBox(panel, -1, 'Nested Classes')
cb2.SetFont(font)
hbox4.Add(cb2, 0, wx.LEFT, 10)
cb3 = wx.CheckBox(panel, -1, 'Non-Project classes')
cb3.SetFont(font)
hbox4.Add(cb3, 0, wx.LEFT, 10)
vbox.Add(hbox4, 0, wx.LEFT, 10)
vbox.Add((-1, 25))
hbox5 = wx.BoxSizer(wx.HORIZONTAL)
btn1 = wx.Button(panel, -1, 'Ok', size=(70, 30))
hbox5.Add(btn1, 0)
btn2 = wx.Button(panel, -1, 'Close', size=(70, 30))
hbox5.Add(btn2, 0, wx.LEFT | wx.BOTTOM , 5)
vbox.Add(hbox5, 0, wx.ALIGN_RIGHT | wx.RIGHT, 10)
panel.SetSizer(vbox)
self.Centre()
self.Show(True)
def OnAboutBox(self, event):
description = """ describe my app here """
licence = """ blablabla """
info = wx.AboutDialogInfo()
info.SetIcon(wx.Icon('icons/icon.png', wx.BITMAP_TYPE_PNG))
info.SetName('')
info.SetVersion('1.0')
info.SetDescription(description)
info.SetCopyright('')
info.SetWebSite('')
info.SetLicence(licence)
info.AddDeveloper('')
info.AddDocWriter('')
info.AddArtist('')
info.AddTranslator('')
wx.AboutBox(info)
app = wx.App()
MyApp (None, -1, 'Go To Class')
app.MainLoop()
Source: (StackOverflow)
I am trying to write a function that copies a string parameter to the clipboard. I intend to use this in a Python script that I've been working on. This is what I have so far (found most this snippet on another stack overflow post):
from tkinter import Tk
def copy_to_clipboard(text):
text = str(text)
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(text)
r.destroy()
My problem is that when the script stops, the copied text is no longer on the clipboard.
Is there any possible alternative or fix to this?
Is there a good platform independent solution to my problem? Or will I have to check for what OS the user is on and proceed from there?
Source: (StackOverflow)
I'm developing an application that contains a number of panes. See the screenshot:

- The left settings pane is a
wx.ScrolledPanel
that contains a number of wx.Panels
.
- The top events pane is a
wx.grid.Grid
.
- The bottom data pane is a
wx.Panel
that contains a wx.grid.Grid
.
- The middle plot pane is a
wx.Panel
containing an enthought chaco plot.
- The right detector pane is a
wx.Panel
.
I would like to implement focus follows mouse so that when I move my mouse over the plot I can immediately zoom in or out using my scroll wheel without first clicking on the plot to give it the focus.
Similarly when I move my mouse over the left settings , the top events or the bottom data panes I would like to be able to immediately scroll the window using the scroll wheel without first clicking on the window.
Currently I defined a function:
def focusFollowsMouse(window):
window.Bind(wx.EVT_ENTER_WINDOW, lambda event: window.SetFocus())
I would like to apply this function only on the four top-level panes: plot, settings, events and data.
However I need to call this function for each sub-panel or control in each of the top-level panes to get this to work. For example I need to apply this function individually to the Measurement Settings, Analysis Parameters, View Settings etc. panels.
Most likely the EVT_ENTER_WINDOW
event is not propagated to parent windows.
Is there a way to get this to work without applying focusFollowsMouse
to each and every sub-panel or control?
Thanks
Source: (StackOverflow)
I can bind an event to a textctrl box np. The problem is I have to be clicked inside of the textctrl box to "catch" this event. I am hoping to be able to catch anytime someone presses the Arrow keys while the main window has focus.
NOT WORKING:
wx.EVT_KEY_DOWN(self, self.OnKeyDown)
WORKING:
self.NudgeTxt = wx.TextCtrl(self.panel, size=(40,20), value=str(5))
wx.EVT_KEY_DOWN(self.NudgeTxt, self.OnKeyDown)
I am pretty sure I am missing something easy. However am a bit stuck.
Source: (StackOverflow)
I want a simple gui for one of may apps and am a noob when it comes gui itself. Tkinter and wxpython are the two standards in python i see.. Which one is simpler and more intuitive?
Source: (StackOverflow)