About Creating New Packages/Widgets & Other Dev Help

I’ve created quite a few widgets for my projects over the years…

Basically when I started wxPython I was slapping together a lot of widgets to
make a new widget(s) that performed the functions I wanted and looked right
natively for my/the various platforms used. Oftentimes, these widgets didn’t
have all the functionality that I wanted…

What I wanted/desired was the Ultimate Widget for the purpose at hand.

This list entails questions for Robin and other wxPython developers as to what
the best practices are when doing this to make integrating new stuff with the
standard wxPython library as painless as possible. Also various questions to
rack the developers brains as to Who-What-When-Where-Why-How-Huh and then
some other random stuff are welcome here.

Along this route and through my learning, there are many ways these widgets
can be produced:
Examples:

  1. Generically(Ex: Slap 2 or more different widgets into a panel and call it a day…)
  2. Create a custom wx.PyControl/wx.Control with basic events all handled specifically and classed out properly.
  3. Other… / Transmogrify(Calvin & Hobbes style)…

Lets begin…

Attached are images of some of my works and works-in-progress.
Most are solely mine own creations with some being modified/improved
widgets(wxPython licensed).

ShapedBitmapButton, ThreeWaySplitter, VolumeCtrl

RoundTable #1 of questions??? (DC, Device Context)

ShapedBitmapButton.png

ThreeWaySplitter.png

VolumeCtrl.png

···

=============================

  1. How many different DC types are there?

  2. What is the best performing DC’s for drawing graphics?

  3. Any other knowledge for improving drawing performance such as a game. Lookup Ex: library vs. global vs. local

  4. Infos about module Docstring markup? What is the standard for Classic vs. Phoenix

ShapedBitmapButton is the Ultimate widget I have long desired for a long time.
I have finally gotten to the point that I have gotten it(the widget) to completely
work with alpha images correctly and also draws the underlying widgets background
colour/bitmap/etc underneath it acceptably also performance-wise with pure wxPy/Python.
Looking for drawing performance suggestions/knowledge. Dumbed down Version and Full Featured Version.

ThreeWaySplitter is a modification of Andrea’s FourWaySplitter to meet
the simple/more often useable/customizable side with adjusting sashes without
all the pain in the ass of having to click twice or more to get the same resulting
sash position with normal sash layouts or FourWaySplitter.
Looking for suggestions/ideas of improvement for sashes, and custom drawn sashes(maybe bitmaps).

VolumeCtrl is a self explanitory.
Looking for infos on how to change the OS’s volume programatically/pythonically.
In particular, on a Mac, but also on your flavor of linux(might be different ways/change it).

I’m not the best documentarist, and have basically replicated a lot of Andrea’s
Docstring style(rst or epydoc). Is this right and up to par with the docs generation
for classic and phoenix? Best Links for easy learning or copying of wxPy markup style?

Related to Other Dev Help
When I am working on a new wxPython GUI and there is a notebook widget in
it, I sometimes add a PyShell, PySliceShell and PyCrust pages to help debug
things. Although there is a specific demo showing PyCrust why not add these
pages to the demo notebook. Perhaps make them hide-able.

I sometimes add a page (panel with textctrl) showing sys.modules and a page
with sys.path.

Metallicow wrote:

Attached are images of some of my works and works-in-progress.
Most are solely mine own creations with some being modified/improved
widgets(wxPython licensed).

ShapedBitmapButton, ThreeWaySplitter, VolumeCtrl

RoundTable #1 of questions??? (DC, Device Context)

1. How many different DC types are there?

>>> import wx
>>> for x in dir(wx):
... if x.endswith('DC'):
... print('wx.%s' % x)

2. What is the best performing DC's for drawing graphics?

It depends on the context. In a EVT_PAINT you must use a wx.PaintDC, or one derived from it. Outside of EVT_PAINT handlers you should use wx.ClientDC but modern hardware and OS tend to perform better if you do all your drawing in the paint handler. So when you need to update something on screen outside of the paint handler then the best approach is to just change the object's state and then call Refresh and wait for the next paint event and then redraw based on the changed state.

The buffered DCs will buffer your drawing operations in a wx.Bitmap and then flush them all at once to the screen using a normal DC, reducing or preventing flicker. However on platforms that already buffer drawing operations, or where it can be turned on programatically, then using your own buffering is overkill, unless you are maintaining the buffer bitmap too, or are simulating multiple layers.

Finally, if you want anti-aliased drawing or alpha transparency then you should use wx.GraphicsContext as a layer above the DCs

3. Any other knowledge for improving drawing performance such as a game.
Lookup Ex: library vs. global vs. local

4. Infos about module Docstring markup? What is the standard for Classic
vs. Phoenix

Use reStructuredText. There is a bit in the wiki in the Phoenix section about this.

···

--
Robin Dunn
Software Craftsman

...

I'm not the best documentarist, and have basically replicated a lot of Andrea's
Docstring style(rst or epydoc). Is this right and up to par with the docs generation
for classic and phoenix? Best Links for easy learning or copying of wxPy markup style?

In Phoenix Andrea switched to using rst/Sphinx from epydoc which he at some point used his agw stuff.

The guidelines are here:
http://wxpython.org/Phoenix/docs/html/DocstringsGuidelines.html

Werner

···

On 18/01/2014 23:49, Metallicow wrote:

Ok, so I checked out the various DC’s and it seems BufferedPaintDC works fine for ShapedBitmapButtons purposes.
Had some crashy issues with GraphicsContext, so not sure if I am trying to use it correctly; also I dont think it should be required for this
as the input image should handle all graphical issues… maybe this would differ a bit with SVG when I get all that stuff figured out…
Just PNG/GIF should be fine for starters. Users can programmatic re/scaling of the images should handle the rest if needing slight sizing tweaks.

I think I have worked out all the bugs with the various sizers types/situations, so, ok there ATM…
Tho still need to tweak the dc stuff if using a dc gradient or whatever. Major fubar havok ensues followed by imminent CTD when scruntching the frame to zilch or less than dc.GetAsBitmap if image size is bigger. Gradient scaling issue…
If I can’t figure this one out with a decent fix, then dc background support may have to be put on the side burner for a while…

Also read up on phoenix rst a bit. I think I have a general understanding of it now… I need to test render it tho first to make sure…

More questions:

  1. What would be the easiest way for me to generate the html docs for just my few modules with the sphinx generator, so as to test what they will look like. I didn’t find any documentation on the phoenix page.
  2. I read a bit about mixins on someones site… rumor is…
    Ex:

class MyClass(wx.Frame, MyMixin):
vs.
class MyClass(MyMixin, wx.Frame):

Does Inheritance Position/Order really matter? If so which one is correct?

  1. When binding events in a mixin, does lambda provide any extra benefits? If so How/Why?
    SmartHighlighting Ex: if extra functionality is desired without overwriting the default handler. Im guessing event.Skip() should always be wisely placed somewhere in the event(beginning or end).

  2. Is it prefered that short sample apps be in a library resource at the end of the file? Or should they explicitly be seperate?
    Ex:

if name == ‘main’:
testApp

Attached Progress pics. Getting closer…

Metallicow wrote:

More questions:
1. What would be the easiest way for me to generate the html docs for
just my few modules with the sphinx generator, so as to test what they
will look like. I didn't find any documentation on the phoenix page.

You could use the Sphinx tools directly for initial tests. You will also want to have the Phoenix build tool build the docs before you you are finished, as it does some post processing of the generated text files before running it all through Sphinx. So you will want to make sure that those tweaks are done correctly for your documentation. Once you have done the first pass of generating all of the docs then subsequent updates do not take too long to process so it isn't too bad to just run the build.py commands for your intermediate testing too.

2. I read a bit about mixins on someones site... rumor is...
Ex:

    class MyClass(wx.Frame, MyMixin):

vs.

    class MyClass(MyMixin, wx.Frame):

Does Inheritance Position/Order really matter?

Yes. It determines the MRO (Method Resolution Order) which is what determines which instance of a method it uses when you call it, and which is the next one called if the method uses super().

If so which one is correct?

It depends.

3. When binding events in a mixin, does lambda provide any extra
benefits?

No, not any beyond using a lambda in a non-mixin class hierarchy.

SmartHighlighting Ex: if extra functionality is desired without
overwriting the default handler. Im guessing event.Skip() should always
be wisely placed somewhere in the event(beginning or end).

It doesn't really matter where it is called. It just sets a flag that is checked after the event handler returns.

4. Is it prefered that short sample apps be in a library resource at the
end of the file? Or should they explicitly be seperate?

Yes, all of the above. I think it is nice to have a simple "smoke test"[1] in the module itself that just proves that it works and not much (if any) more. Then there should be a module in the demo that shows a real-world example of the widget in as close to a real-world context as possible, and which also includes overview text and detailed comments that a newbie can use to learn about how to use the widget. Finally, there should be a module added to unittests that fully exercises as much of the code as possible and which includes cross-checking and asserts to verify things like intermediate results, that events were sent/received, that expected failures happened, etc.

[1] This term comes from the hardware world where the test consists of applying power to the device being tested and if there is no smoke, sparks, melting components or other signs of fundamental failure then the test passes.

···

--
Robin Dunn
Software Craftsman

Happy Holidays all, Robin and wxPythoneers!
… some pics and updates from the SourceCoder guru…
Snakey get out from under that tree! No peaking.

Got substantial progress on the ULTIMATE (Pic)ShapedBitmapButton(See pic with 3 overlayed/parents/childs all working with ALPHA!!!)
… Also …
…(Pic) of a custom CheckListBoxSTC(highly customizable).
…(Pic) Ahhh and also the SourceCoder’s only Dynamic Reloader in action(Pure wxPy genius).
…(Pic) The glCanvas can do many things, but we aim to implement many new general classes for wxUsers.
…(Pic) and onto Go watch the “Grinch stole christmas” on MediaCtrl.

… the coal… Also about a million mixins for various default wx classes. gold separately.
Snakey also wants Robin to all kill the evil whitespace demons in the wxPyChimney this holiday! :slight_smile:

Update: wxPy timeit tests confirm ScreenDC as the fastest DC, if users have a choice in the matter.

SBB_preview_christmas2015.png

glCanvas_pic1.png

checklistboxSTC.png

holiday_mediactrl_logo.png

dynamic_reloader.png

snakey128.png

Well… Yea. I now see that it DOES really matter where event.Skip() is placed,
but only in instances where the code is doing ALOT of stuff and you want to
choose specifically when to call the func.
I noticed this in very in-depth tests with my ShapedBitmapButton.
Like you said… normally this shouldn’t matter much.
… But it does matter sometimes…
…especially in (recursive) loops and (recursive) event loops…
…urg… my head is spinning again…

Thanks Robin.

···

On Friday, February 7, 2014 at 3:08:06 PM UTC-6, Robin Dunn wrote:

Metallicow wrote:

SmartHighlighting Ex: if extra functionality is desired without

overwriting the default handler. Im guessing event.Skip() should always

be wisely placed somewhere in the event(beginning or end).

It doesn’t really matter where it is called. It just sets a flag that
is checked after the event handler returns.


Robin Dunn

Software Craftsman

http://wxPython.org

Happy Holidays all, Robin and wxPythoneers!
… some pics and updates from the SourceCoder guru…
Snakey get out from under that tree! No peaking.

Got substantial progress on the ULTIMATE (Pic)ShapedBitmapButton(See pic with 3 overlayed/parents/childs all working with ALPHA!!!)
… Also …
…(Pic) of a custom CheckListBoxSTC(highly customizable).
…(Pic) Ahhh and also the SourceCoder’s only Dynamic Reloader in action(Pure wxPy genius).
…(Pic) The glCanvas can do many things, but we aim to implement many new general classes for wxUsers.
…(Pic) and onto Go watch the “Grinch stole christmas” on MediaCtrl.

… the coal… Also about a million mixins for various default wx classes. gold separately.
Snakey also wants Robin to all kill the evil whitespace demons in the wxPyChimney this holiday! :slight_smile:

Update: wxPy timeit tests confirm ScreenDC as the fastest DC, if users have a choice in the matter.

This is definitely not the case on Mac. On that platform (or any drawing API that is natively double-buffered) ScreenDC will really kill performance. When doing performance timing, it’s important to remember that wxPython on Windows, Mac and Linux are essentially three different libraries. They share an API, but much of the actual implementation is different. So if you’re targeting wxPython components for general use, it’s important to performance test on all major platforms or to use recommended best practices, like drawing using PaintDC from an OnPaint event.

Regards,

Kevin

···

On Dec 24, 2015, at 3:20 AM, Metallicow metaliobovinus@gmail.com wrote:

You received this message because you are subscribed to the Google Groups “wxPython-dev” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxPython-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

<SBB_preview_christmas2015.png><glCanvas_pic1.png><checklistboxSTC.png><holiday_mediactrl_logo.png><dynamic_reloader.png><snakey128.png>

Metallicow wrote:

SmartHighlighting Ex: if extra functionality is desired without

overwriting the default handler. Im guessing event.Skip() should always

be wisely placed somewhere in the event(beginning or end).

It doesn’t really matter where it is called. It just sets a flag that
is checked after the event handler returns.


Robin Dunn

Software Craftsman

http://wxPython.org

Well… Yea. I now see that it DOES really matter where event.Skip() is placed,
but only in instances where the code is doing ALOT of stuff and you want to
choose specifically when to call the func.
I noticed this in very in-depth tests with my ShapedBitmapButton.
Like you said… normally this shouldn’t matter much.
… But it does matter sometimes…
…especially in (recursive) loops and (recursive) event loops…
…urg… my head is spinning again…

No, it doesn’t matter in terms of Skip’s effect. Calling Skip does not take effect until the function calling it returns. This is 100% always true. :slight_smile: But it is also true that every function call you make has a minor performance impact, even if it does nothing but set a variable, as simply calling the function does take some small amount of CPU time. So what is probably happening is that with all the recursion and loops you’re running, those milliseconds are adding up and causing the subsequent calls after Skip to happen at slightly different times, like 1ms later after the first call, 2ms later after the second, etc. and soon some operations are happening a second later, or more.

When moving around inconsequential calls like event.Skip() makes a difference in app behavior, it usually indicates that there is a performance problem somewhere else in the app. Generally speaking, having lots of recursion and events firing makes things hard to debug and should be avoided if possible. I can’t say much else without seeing the code, but if you’ve only been testing this on one machine, I’d recommend testing on other machines with significantly different specs, if you have one available, and see if your results match. That will help give you an idea of if your fix is a general purpose fix or just appears to fix the problem on a particular test machine.

Regards,

Kevin

···

On Dec 24, 2015, at 4:13 AM, Metallicow metaliobovinus@gmail.com wrote:
On Friday, February 7, 2014 at 3:08:06 PM UTC-6, Robin Dunn wrote:

Thanks Robin.

You received this message because you are subscribed to the Google Groups “wxPython-dev” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxPython-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Re: ShapedBitmapButton loopage of events…

I have tested quite a bit on windows and it does work on a couple versions of linux kubuntu and mageia. Not actually tested yet on a mac…
The basic concept of the madness at play here is that all classes in the family tree might/will get the event at least once. This probably sounds
like quite a bit of overkill but it is needed when the buttons(rects) are “overlayed” in any such way for the alpha drawing to work and also for
animations of the buttons to display correctly. This advanced behaviour is only needed if they are overlayed, otherwise a simple sizer keeps them from fighting and the
crazy looping is not needed. There needs to be built a draw list, quadrant list, order list and a giveup(the event"Skip", so the end built bitmap is draw right on top) window for every event processed.
So what is happening is that the same method(s) recurse within the same class over and over passing the event to its siblings/parents/etc/etc instances
until the top is reached or drawing has stopped because another accepts the responsibility of really processing the event. It is essentially conditional logic
when it comes down to when or if Skip is called, because the original widget that fired the event may not be the one who is going to say Skip, if at all.
Local opts and killing all the dots has helped quite a bit with performance. But there is a bit of lag when about 100 or more get into the same room or with a moving
WrapSizer.
Or in other words, I am recreating the same event for the sibling and parent widgets every check, while still maintaining an passing the “event” “loop”, but sorta actually ate it.
Maybe that makes better sense. Like playing hot potato until somewidget drops it.
I’m not quite sure exactly how to explain it or document it. I just know I’ve spent a huge amount of time line by line trying to perfect it. and as a basic widget
it works superbly already. Just some of the more advanced techniques when applied still need smoothing out… like the overlaying and smooth move animations.

···

On Thursday, December 24, 2015 at 10:07:10 AM UTC-6, kevino wrote:

When moving around inconsequential calls like event.Skip() makes a difference in app behavior, it usually indicates that there is a performance problem somewhere else in the app. Generally speaking, having lots of recursion and events firing makes things hard to debug and should be avoided if possible. I can’t say much else without seeing the code, but if you’ve only been testing this on one machine, I’d recommend testing on other machines with significantly different specs, if you have one available, and see if your results match. That will help give you an idea of if your fix is a general purpose fix or just appears to fix the problem on a particular test machine.

Regards,

Kevin

When moving around inconsequential calls like event.Skip() makes a difference in app behavior, it usually indicates that there is a performance problem somewhere else in the app. Generally speaking, having lots of recursion and events firing makes things hard to debug and should be avoided if possible. I can’t say much else without seeing the code, but if you’ve only been testing this on one machine, I’d recommend testing on other machines with significantly different specs, if you have one available, and see if your results match. That will help give you an idea of if your fix is a general purpose fix or just appears to fix the problem on a particular test machine.

Regards,

Kevin

Re: ShapedBitmapButton loopage of events…

I have tested quite a bit on windows and it does work on a couple versions of linux kubuntu and mageia. Not actually tested yet on a mac…
The basic concept of the madness at play here is that all classes in the family tree might/will get the event at least once. This probably sounds
like quite a bit of overkill but it is needed when the buttons(rects) are “overlayed” in any such way for the alpha drawing to work and also for
animations of the buttons to display correctly. This advanced behaviour is only needed if they are overlayed, otherwise a simple sizer keeps them from fighting and the crazy looping is not needed. There needs to be built a draw list, quadrant list, order list and a giveup(the event"Skip", so the end built bitmap is draw right on top) window for every event processed.

Are you using a series of controls with sizers to do the layout for a custom-drawn button?

Regards,

Kevin

···

On Dec 26, 2015, at 4:33 AM, Metallicow metaliobovinus@gmail.com wrote:
On Thursday, December 24, 2015 at 10:07:10 AM UTC-6, kevino wrote:

So what is happening is that the same method(s) recurse within the same class over and over passing the event to its siblings/parents/etc/etc instances
until the top is reached or drawing has stopped because another accepts the responsibility of really processing the event. It is essentially conditional logic
when it comes down to when or if Skip is called, because the original widget that fired the event may not be the one who is going to say Skip, if at all.
Local opts and killing all the dots has helped quite a bit with performance. But there is a bit of lag when about 100 or more get into the same room or with a moving
WrapSizer.
Or in other words, I am recreating the same event for the sibling and parent widgets every check, while still maintaining an passing the “event” “loop”, but sorta actually ate it.
Maybe that makes better sense. Like playing hot potato until somewidget drops it.
I’m not quite sure exactly how to explain it or document it. I just know I’ve spent a huge amount of time line by line trying to perfect it. and as a basic widget
it works superbly already. Just some of the more advanced techniques when applied still need smoothing out… like the overlaying and smooth move animations.

You received this message because you are subscribed to the Google Groups “wxPython-dev” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxPython-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Nope. ShapedBitmapButton is just a hand-built wx.Control Subclass.
So 1 Button instance is just like 1 Button instance when created. This way it is a dropin replacement basically.
ShapedBitmapButtonAdv is a subclass of ShapedBitmapButton
With the advanced techniques the button instances “talk” or “discuss” with each other about what event is really going on and how to draw. Then process the event
which in turn not really “walks back down the tree” and redraws the original button correctly as if that instance is the actual instance.
I have tested the basic class with absolute positioning and have tests for all the different sizers, so the basic class is pretty solidly tested.
I guess it could be explained like this also… ummm
The event has to be recreated exactly(signed by the lead) and passed around like a charter to sign basically…

···

On Saturday, December 26, 2015 at 11:33:06 AM UTC-6, kevin...@theolliviers.com wrote:

Are you using a series of controls with sizers to do the layout for a custom-drawn button?

Regards,

Kevin

Are you using a series of controls with sizers to do the layout for a custom-drawn button?

Regards,

Kevin

Nope. ShapedBitmapButton is just a hand-built wx.Control Subclass.
So 1 Button instance is just like 1 Button instance when created. This way it is a dropin replacement basically.
ShapedBitmapButtonAdv is a subclass of ShapedBitmapButton
With the advanced techniques the button instances “talk” or “discuss” with each other about what event is really going on and how to draw. Then process the event
which in turn not really “walks back down the tree” and redraws the original button correctly as if that instance is the actual instance.
I have tested the basic class with absolute positioning and have tests for all the different sizers, so the basic class is pretty solidly tested.
I guess it could be explained like this also… ummm
The event has to be recreated exactly(signed by the lead) and passed around like a charter to sign basically…

Gotcha. This just seems a fairly complex system to draw some buttons, and I’m wondering what issue exactly this system was built to resolve. Is this the overlap thing you mentioned earlier? wx.DC uses very dated APIs on Windows that don’t support a lot of modern drawing operations, and so sometimes very simple drawing tasks become a huge hassle to implement. Multi-control transparency particularly can be a huge headache because the Win implementation of wx.DC uses APIs that really pre-date transparency support entirely. (MS bolted on some transparency support later, but it only works in certain circumstances.) Often, you can get better results simply by using wx.GraphicsContext or, as Chris mentioned in another thread, wx.GCDC if you want to get the good stuff but keep your code as-is.

Regards,

Kevin

···

On Dec 28, 2015, at 6:54 PM, Metallicow metaliobovinus@gmail.com wrote:
On Saturday, December 26, 2015 at 11:33:06 AM UTC-6, kevin…@theolliviers.com wrote:

You received this message because you are subscribed to the Google Groups “wxPython-dev” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxPython-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

I have been thinking about duplicating/tweaking the class to test with wx.GraphicsContext and or wx.GCDC but haven’t got there yet.
I’ll have to read up on the differences between them and test/see if there is any visual or performance differences at that point.
… But yea, the classes are built overall for overlap/overlaying issues and alpha drawing(The image is the button, not the alpha), that way I can make just about anything…

For example, the python Qt demo has a demo where the layout images/widgets(absolute positioning) animate when a button is clicked and fly off screen while the new widgets
fly in to create the “next page layout”. That is entirely possible at this point.
Other fancy examples might be a slide in/over the top HUD like a lot for video games have for options screens, etc…
… It could even go as far as making a “web page” lookalike.
It just really depends on the artists good looking art and how far they want to take it with the level of detail.

…And when I get it 99.9% finalized in python someday… Then if I can manage to grok/port it into C++ correctly which will really speed up the drawing performance, that would be awesome.

···

On Tuesday, December 29, 2015 at 4:00:19 PM UTC-6, kevino wrote:

On Dec 28, 2015, at 6:54 PM, Metallicow metalio...@gmail.com wrote:

On Saturday, December 26, 2015 at 11:33:06 AM UTC-6, kevin…@theolliviers.com wrote:

Are you using a series of controls with sizers to do the layout for a custom-drawn button?

Regards,

Kevin

Nope. ShapedBitmapButton is just a hand-built wx.Control Subclass.
So 1 Button instance is just like 1 Button instance when created. This way it is a dropin replacement basically.
ShapedBitmapButtonAdv is a subclass of ShapedBitmapButton
With the advanced techniques the button instances “talk” or “discuss” with each other about what event is really going on and how to draw. Then process the event
which in turn not really “walks back down the tree” and redraws the original button correctly as if that instance is the actual instance.
I have tested the basic class with absolute positioning and have tests for all the different sizers, so the basic class is pretty solidly tested.
I guess it could be explained like this also… ummm
The event has to be recreated exactly(signed by the lead) and passed around like a charter to sign basically…

Gotcha. This just seems a fairly complex system to draw some buttons, and I’m wondering what issue exactly this system was built to resolve. Is this the overlap thing you mentioned earlier? wx.DC uses very dated APIs on Windows that don’t support a lot of modern drawing operations, and so sometimes very simple drawing tasks become a huge hassle to implement. Multi-control transparency particularly can be a huge headache because the Win implementation of wx.DC uses APIs that really pre-date transparency support entirely. (MS bolted on some transparency support later, but it only works in certain circumstances.) Often, you can get better results simply by using wx.GraphicsContext or, as Chris mentioned in another thread, wx.GCDC if you want to get the good stuff but keep your code as-is.

Regards,

Kevin

You received this message because you are subscribed to the Google Groups “wxPython-dev” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxPython-dev...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Are you using a series of controls with sizers to do the layout for a custom-drawn button?

Regards,

Kevin

Nope. ShapedBitmapButton is just a hand-built wx.Control Subclass.
So 1 Button instance is just like 1 Button instance when created. This way it is a dropin replacement basically.
ShapedBitmapButtonAdv is a subclass of ShapedBitmapButton
With the advanced techniques the button instances “talk” or “discuss” with each other about what event is really going on and how to draw. Then process the event
which in turn not really “walks back down the tree” and redraws the original button correctly as if that instance is the actual instance.
I have tested the basic class with absolute positioning and have tests for all the different sizers, so the basic class is pretty solidly tested.
I guess it could be explained like this also… ummm
The event has to be recreated exactly(signed by the lead) and passed around like a charter to sign basically…

Gotcha. This just seems a fairly complex system to draw some buttons, and I’m wondering what issue exactly this system was built to resolve. Is this the overlap thing you mentioned earlier? wx.DC uses very dated APIs on Windows that don’t support a lot of modern drawing operations, and so sometimes very simple drawing tasks become a huge hassle to implement. Multi-control transparency particularly can be a huge headache because the Win implementation of wx.DC uses APIs that really pre-date transparency support entirely. (MS bolted on some transparency support later, but it only works in certain circumstances.) Often, you can get better results simply by using wx.GraphicsContext or, as Chris mentioned in another thread, wx.GCDC if you want to get the good stuff but keep your code as-is.

Regards,

Kevin

You received this message because you are subscribed to the Google Groups “wxPython-dev” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxPython-dev...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

I have been thinking about duplicating/tweaking the class to test with wx.GraphicsContext and or wx.GCDC but haven’t got there yet.
I’ll have to read up on the differences between them and test/see if there is any visual or performance differences at that point.
… But yea, the classes are built overall for overlap/overlaying issues and alpha drawing(The image is the button, not the alpha), that way I can make just about anything…

Basically, when you use wx.GraphicsContext or wx.GCDC, it is like using wx.BufferedPaintDC to draw into an offscreen buffer first, but the buffering is done by the OS itself. When drawing is buffered, you get alpha buffering “for free”. Handling controls with transparency is no different from drawing any other control, often you just have to set an alpha value for the drawing operations you want to have some level of alpha. When the OS draws the overlapping controls to screen, it automatically applies any alpha transparency. If done right using wx.GCDC, I suspect you could delete all the event forwarding code and it would work the same, though I’m not 100% certain because Win APIs can be pretty wonky at times.

Also, if this code is intended to be cross-platform, you might want to get someone to try your code on Mac if you haven’t already, as well as Linux. My guess is that your workarounds assume that all drawing is painted directly to the screen, which is true for wxWidgets on Windows but not on Mac (the OS buffers all drawing on Mac), and I am pretty sure also sometimes not on Linux either.

Regards,

Kevin

···

On Jan 3, 2016, at 1:35 AM, Metallicow metaliobovinus@gmail.com wrote:
On Tuesday, December 29, 2015 at 4:00:19 PM UTC-6, kevino wrote:

On Dec 28, 2015, at 6:54 PM, Metallicow metalio...@gmail.com wrote:
On Saturday, December 26, 2015 at 11:33:06 AM UTC-6, kevin…@theolliviers.com wrote:

For example, the python Qt demo has a demo where the layout images/widgets(absolute positioning) animate when a button is clicked and fly off screen while the new widgets
fly in to create the “next page layout”. That is entirely possible at this point.
Other fancy examples might be a slide in/over the top HUD like a lot for video games have for options screens, etc…
… It could even go as far as making a “web page” lookalike.
It just really depends on the artists good looking art and how far they want to take it with the level of detail.

…And when I get it 99.9% finalized in python someday… Then if I can manage to grok/port it into C++ correctly which will really speed up the drawing performance, that would be awesome.

You received this message because you are subscribed to the Google Groups “wxPython-dev” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxPython-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.