473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Skinnable/Stylable windows in wxPython?

I'm very near finishing a medium to large scale application, so I'm
getting a head start on the GUI side of things. Part of the concept is
to give as much attention to presentation as functionality, and
something I really wanted to do was transcend the basic window and
style it to an extent,

To be honest, the wxPopupWindow was basically what I was looking for,
but it isn't available on Mac, eliminating that possibility.
wxShapedWindow would have sufficed, but it uses a more recent version
wxPython that I've chosen not to install for various dependency
issues, so I really can't use that.

I've combed through the demo countless times, but I really can't find
any answers. So, the question: what is the best way (or is there one,
rather) to achieve an end comparable to skinning my wx windows?

Thanks for your help,
Daniel Bickett
Jul 18 '05 #1
5 4397
Hello Daniel,
The wxPopupWindow is also missing several things that would make it
suitable for a frame, like accelerator events. I built a 'chromeless'
picture viewer once using wxPopupWindow and it worked , but it was
missing things I needed because of missing functionality in
wxPopupWindow. IMHO is isn't intended to be used as a full featured
frame.
The only way *I* know how to skin an app in wxWindows is using
wxShapedWindow .wxShapedWindow just changes the frame shape, you then
need to render a background picture and then place elements on that
background for buttons and other controls, you also will have to
implement functionality for those elements so they work like normal
controls, plus a hundred other gotchas.
Skinning is a pain ,and to do it right you probably need to use a
'DoubleBufferedDc' so your elements won't flicker when you click or
move them. I started writing a generic skinner class that does the hard
stuff but when I tested found that it needed to be rewritten using a
DoubleBefferedDC. Maybe someday...
Hope any of this helps maybe others have diffrent ideas.
M.E.Farmer

Jul 18 '05 #2
Solution found!

For the future reference of anyone searching:

The wxPopupWindow can easily be achieved by creating a wxMiniFrame
with absolutely no styles ('0', explicitly). The features of the
wxPopupWindow in the wxPython demo don't come with it, they were
manually added in the demo code, so simply adapting the code should
suffice.

Even as I was typing this message, I realized that this was probably
exactly what wxPopupWindow was, and suddenly this clicked because I
remembered seeing in the wxWindows help files that all of the styles
for wxMiniFrame only worked on Windows and Motif, and it made a point
to note that they didn't work on GTK. So I tried a snippet of code[1]
on my Mac (until then I had been working on a windows box) and, to my
surprise, it worked perfectly.

This raises some questions for me, like why, if the wxPython package
is going to have the wxPopupWindow feature, they don't simply inherit
wxMiniFrame like I did (quite literally, it looks /exactly/ the same
as a wxPopupWindow). Not only would this make it more multi-platform
(I have no access to a GTK machine so I don't know if this works.
Could someone please check?), but it would be more useful, considering
the fact that it is in fact a frame, and wouldn't have the problems
that M.E.Farmer outlined above regarding controls on wxPopupWindows.

Regardless, I'm happy that I've uncovered the answer, and I hope this
helps someone else in the same situation :)

Daniel Bickett

NOTES:
[1] from wxPython.wx import wxMiniFrame, wxPySimpleApp
app = wxPySimpleApp()
frame = wxMiniFrame( None , -1 , '' , size = ( 300 , 150 ) , style = 0 )
frame.Show()
app.MainLoop()
Jul 18 '05 #3
Daniel Bickett wrote:
Solution found!

Not only would this make it more multi-platform (I have no access to
a GTK machine so I don't know if this works. Could someone please
check?)


Looks like it works (I had to change frame.Show() to frame.Show(1)
though, but that could be because it's an old version). One odd thing
though: the Windows version doesn't react to clicking or dragging the
mouse, which seems to be the expected behavior. The GTK version can be
moved by dragging the mouse; even just clicking the mouse moves the
window somewhat down and to the left.

--
"Codito ergo sum"
Roel Schroeven
Jul 18 '05 #4
> > Not only would this make it more multi-platform (I have no access to
a GTK machine so I don't know if this works. Could someone please
check?)
Looks like it works (I had to change frame.Show() to frame.Show(1)
though, but that could be because it's an old version).


No, I think that was a slip on my part when copying the code from one
screen to the next :)
One odd thing
though: the Windows version doesn't react to clicking or dragging the
mouse, which seems to be the expected behavior.
I noted in my second post that the functionality of the window
(clicking and dragging et al) was, even in the wxPopupWindow demo,
implemented by using the EVT macros. Copied from the demo, the code is
as follows:

def OnMouseLeftDown(self, evt):
self.ldPos = evt.GetEventObject().ClientToScreen(evt.GetPositio n())
self.wPos = self.GetPosition()
self.CaptureMouse()

def OnMouseMotion(self, evt):
if evt.Dragging() and evt.LeftIsDown():
dPos = evt.GetEventObject().ClientToScreen(evt.GetPositio n())
nPos = (self.wPos.x + (dPos.x - self.ldPos.x),
self.wPos.y + (dPos.y - self.ldPos.y))
self.Move(nPos)

def OnMouseLeftUp(self, evt):
self.ReleaseMouse()

def OnRightUp(self, evt):
self.Show(False)
self.Destroy()
The GTK version can be
moved by dragging the mouse; even just clicking the mouse moves the
window somewhat down and to the left.


That's interesting... I wonder if using those methods would conflict
at all. Also, while I'm on that note, when double clicking on the
resulting window (after binding those events), double click causes a
non-fatal, yet annoying, traceback saying that "the mouse could not be
released because it has not yet been caught blah blah", so I just
wrapped the contents of OnMouseLeftUp in a try..except..pass.

Daniel Bickett
Jul 18 '05 #5
Daniel Bickett wrote:
Not only would this make it more multi-platform (I have no access to
a GTK machine so I don't know if this works. Could someone please
check?)


Looks like it works (I had to change frame.Show() to frame.Show(1)
though, but that could be because it's an old version).

No, I think that was a slip on my part when copying the code from one
screen to the next :)


I tried again with newer versions (Python 2.3 and wxPython 2.4); the
code runs as-is, without that modification.
One odd thing
though: the Windows version doesn't react to clicking or dragging the
mouse, which seems to be the expected behavior. The GTK version can be
moved by dragging the mouse; even just clicking the mouse moves the
window somewhat down and to the left.

That's interesting... I wonder if using those methods would conflict
at all.


I couldn't reproduce that behaviour this time. It might have had
something to do with the test setup the first time.

--
"Codito ergo sum"
Roel Schroeven
Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
by: Vamsi Mudrageda | last post by:
I am kind of new to Python, and after trying and using wxPython, I found it kind of lacking in easy-to-read documentation, speed at loading, and GUI response-time. So I am looking for an another...
4
by: Zach Shutters | last post by:
I am new to python and working my way through the van Rossum tutorial. I am cursios though about if you can program windows with python? I know I shouldn't worry about this right now but I am...
13
by: Peter Maas | last post by:
Recently I replaced Win2k with Linux on my desktop computer. Using mostly multi-platform software I thought this would be easy. It was not as easy as expected getting wxPython to work. There seemed...
7
by: Bob Swerdlow | last post by:
Anyone have opinions about whether we will be better off using PythonNet or wxPython for the GUI layer of our application on Windows? Our code is all Python and is now running on Mac OS X with...
1
by: Ben | last post by:
Hi, I'm interested in making an application I'm about to start writing skinnable, but I have absolutely no idea where to begin. If anyone has a broad overview of how I would go about it or some...
25
by: TPJ | last post by:
GUI's etc: PyGtk on Windows "(...) So if someone develops mainly for X and just wants to make sure that it is not impossible to run on Windows, you can use PyGTK. (...)", July 2nd, 1999 pyGTK...
0
by: Andrew Clancy | last post by:
Hi, I'm hoping to create a skinnable user control in ASP.Net, using the skin file to keep things streamlined & all in one place/technique. 1st attemp went something like this Test.ascx: <%@...
1
Ali Rizwan
by: Ali Rizwan | last post by:
Hi all, Is there anybody who has made A VB6 form fully skinnable, meaning you can change titlebar and borders and some more special things with labels frames buttons etc? But one thing remember...
2
by: timw.google | last post by:
The subject line says it all. Is there a way to install wxPython on a Windows machine without admin privs? I love the way python doesn't need admin to install locally, and I'd like to try wxPython...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.