95 Commits

Author SHA1 Message Date
Alexandre Detiste
0257f755cf remove most of Python2 compatibility code 2025-02-02 20:17:45 -05:00
David Foster
2117602aea demo: ShortcutEditor: Fix broken call GetMenuBar() 2023-05-20 08:01:05 -04:00
PChemGuy
83dba91a2b Missing required explicit float->int type casting
"therange" variable, used to adjust range of the KnobCtrl, must be an integer.
2022-09-03 16:31:12 +03:00
Scott Talbert
58682ecaf4 Update demos to work wxWidgets 3.1.6 2022-05-02 22:36:44 -04:00
Scott Talbert
173d079681 Fix a bunch of Python 3.10 issues with pure-Python classes and demos
In Python 3.10, a change[1] was implemented where extension functions
that take integer arguments will no longer silently accept non-integer
arguments (e.g., floats) that can only be converted to integers with a
loss of precision.  This PR fixes most of these issues in the pure-Python
classes and demos by explicitly converting the parameters to int before
passing them to wxWidgets.  There is loss of precision, but this was
happening before (automatically) anyway as most wxWidgets DeviceContext
functions operate using integers.

Additionally, the PR fixes a few sizing issues, mostly with SpinCtrls being
too small on GTK3.

This is an example of the relevant exception:
Traceback (most recent call last):
  File "/usr/lib64/python3.10/site-packages/wx/lib/agw/pygauge.py", line 355, in OnPaint
    r.width = w
TypeError: 'float' object cannot be interpreted as an integer

Fixes #2038.

[1] https://bugs.python.org/issue37999
2021-12-01 14:19:00 -05:00
cbeytas
7b02c88a28 Merge branch 'master' into treefixes 2021-01-10 03:04:29 +00:00
eagerm
846a4f4e4a Remove unused sizer, add spacing to controls. 2020-11-16 12:31:00 -08:00
eagerm
4bef428bce Add documentation to demo programs. 2020-11-16 12:07:45 -08:00
eagerm
4c6b725479 Create ThumbDemoConfig.py from class in ScrolledThumbnail & ThumbnailCtrl
Add import statements to ScrolledThumbnail and ThumbnailCtrl.
Remove unneeded imports.
2020-11-12 09:40:00 -08:00
eagerm
d6727e5ce7 Create ThumbDemoConfig class
class ThumbDemoConfig contains the user interface and controls used
by both ScrolledThumbnail and ThumbnailCtrl.

Functions which are different between the two demos are overwridden
by each demo.
2020-11-11 12:38:54 -08:00
eagerm
6fa88e361f Reduce differences between demo/ScrolledThumbnail and demo/ThumbnailCtrl 2020-11-10 20:20:34 -08:00
eagerm
e73d5f49db Minor cleanup and fixes from code review
demo/agw/ScrolledThumbnail.py:
  Set frame size to (850, 800).
  Decrease left side of splitter.
  Use default font.
  Remove SetAutoLayout()
  Fix THUMB_OUTLINE_NONE, etc. not found.
demo/agw/Thumbnailctrl.py:
  Set frame size to (850, 800).
  Make scroll instance variable, not local.
  Replace self.TC with self.scroll.
  Decrease left side of splitter.
  Use default font.
  Remove SetAutoLayout().
2020-11-10 20:12:54 -08:00
eagerm
f511c293cc Add ScrolledThumbnail demo
New:  demo/agw/ScrolledThumbnail.py
2020-10-28 09:57:14 -07:00
eager
81c0461233 Refactor ThumbnailCtrl, create stand-alone ScrolledThumbnail widget
ThumbnailCtrl is more of a image browser demo application than a widget,
in that it reads files from a directory, selects which files to display,
deletes files, displays the source directory path in a text ctrl, etc.
This makes it unlikely that it could be used in any other application,
for example, to provide thumbnails of files with different file types
than the ones hard-coded in the class.

ThumbnailCtrl delegates most of its operations to ScrolledThumbnail
which actually implements a scrolled window of thumbnails, a Thumb class,
which contains information about a thumbnail, and an ImageHandler class,
which manipulates images.  There was poor isolation of functionality
between these classes, violating object-oriented design, with one class
making changes to the internal data of another class.  Additionally, there
was substantial non-functional code, as well as code which did not
function correctly.

This refactoring maintains the functionality and interfaces of
ThumbnailCtrl, except for those which were unused.  Existing uses of
the thumbnailctrl package should work without modification.  A new package,
scrolledthumbnail, contains the functionality for a scrolled window
containing thumbnails, an extendable Thumb class, and image manipulation
classes.  The scrolledthumbnail package can be used in other applications,
independent of the ThumbnailCtrl class, and without the functional
restrictions of that application.

Detailed changes:

ThumbnailCtrl.py (demo program):
 - Always import from wx.lib.agw
 - Optional code to use PIL instead of native image handling
 - Add setting for thumbnail width and height
 - Increase size of demo window

thumbnailctrl.py:
 - Move Thumb, ScrolledThumbnail, ImageHandler to scrolledthumbnail.py
 - Remove EVT_THUMBNAILS_CAPTION_CHANGED (unused)
 - Add EVT_THUMBNAILS_CHAR to respond to keystrokes
 - Remove image processing code
 - Add scrolling dialog for delete files
 - Move directory processing from ScrolledThumbnail
 - Move file delete processing from ScrolledThumbnail
 - List all files to be deleted in scrolling dialog
 - Remove unused or unimplemented methods and options

scrolledthumbnail.py:
 - Move Thumb, ScrolledThumbnail, ImageHander classes from thumbnailctrl.py
 - Add documentation for ScrolledThumbnail widget
 - Add example program which does not use ThumbnailCtrl
 - New EVT_THUMBNAILS_CHAR event for key press
 - Remove unused options and dead code
 - Add Rotate() to PILImageHandler and NativeImageHandler
 - Throw event EVT_THUMBNAILS_CHAR for keystroke on thumbnail
 - Fix failure to rotate images correctly
 - Redisplay window when thumb size changed
 - Simplify logic
 - Remove popup dialog when rotating images
2020-10-28 09:56:35 -07:00
Jorge Moraleda
e7b86c546f Remove inconsistent layout flags that prevent XLSGrid demo from running 2020-07-21 18:00:40 -07:00
Metallicow
542a32c17d Optimize Colour Brush Pen
Use builtin Colours, Brushes, Pens where needed. They are faster.
2020-07-19 23:48:39 -05:00
Robin Dunn
d265d13f6c Spelling fixes in the demo 2020-07-14 12:00:55 -07:00
Robin Dunn
5be2356b2c SASH_STATUS_OUT_OF_RANGE is in wx.adv 2020-04-07 19:14:32 -07:00
Robin Dunn
7a05d20d82 Merge pull request #1572 from pbrod/Fix_issue1571
Fixes issue 1571:
2020-03-23 16:07:22 -07:00
Robin Dunn
41c5af9cde Merge pull request #1569 from pbrod/Fix_issue1554
Fixes issue # 1554:
2020-03-23 15:35:41 -07:00
Per A. Brodtkorb
e4e8bf8317 Fixes issue 1571:
Adding missing close for open.
If the "close()" call is missing after a "open(filename)" call, the filename isn't guaranteed to be closed before the interpreter exits.
This is generally a bad practice as explained here: https://stackoverflow.com/questions/7395542/is-explicitly-closing-files-important

Also replaced "fid=open(filename) fid.close()" statements for files with the safer
"with open(filename) as fid:" blocks. See https://www.python.org/dev/peps/pep-0343/
2020-03-23 17:16:44 +01:00
Per A. Brodtkorb
fc1823315b Fixes issue # 1554:
Replaced "== None" and "!= None" with "is None" and "is not None", respectively, because the former is slower and error-prone.
2020-03-23 11:53:36 +01:00
Per A. Brodtkorb
033c18fd9f Fixes issue #1556
Replaced XXX.keys() calls with idiomatic python 3 calls that are compatible with python 2 such as eg:
 * replaced "y = xxx.keys()" or "y = list(xxx.keys())" with just "y = list(xxx)"
 * replaced "sorted(xxx.keys())" or "sorted(list(xxx.keys()))" with just "sorted(xxx)"
 * replaced "if not A in B.keys():" with "if A not in B:"
 * replaced "for A in B.keys():"  with "for A in B:"

See also https://python-future.org/compatible_idioms.html
https://python-future.org/compatible_idioms.html#dict-keys-values-items-as-a-list
2020-03-20 18:51:19 +01:00
Robin Dunn
f55917037e Resizing of Bitmaps and Icons no longer supported on OSX. Load into a wx.Image and Rescale there. 2020-03-13 10:41:15 -07:00
topic2k
a376bf8bb8 Use default position for PopupMenu in demo.agw.UltimateReportDemo.TestFrame 2019-10-23 09:46:24 +02:00
topic2k
2f19c5a0eb Use default position for PopupMenu in demo.agw.AUI.AuiFrame 2019-10-23 09:33:12 +02:00
Robin Dunn
1cbde7b685 Use wx.LIGHT_GREY as the default colour, it is closer to the real default background 2019-10-07 15:33:31 -07:00
Robin Dunn
4fe640b9d5 Leave a bit of space between the controls 2019-10-07 15:18:24 -07:00
Robin Dunn
50b9cfd95a Don't start out with a transparent colour, the ColourDialog on OSX will not change it without extra steps 2019-10-07 15:17:53 -07:00
Robin Dunn
0eba88c53a cockie --> cookie 2019-10-07 15:16:36 -07:00
Robin Dunn
8395898ea5 Merge branch 'improve-hypertreelist' of https://github.com/ThomasP0815/Phoenix into ThomasP0815-improve-hypertreelist 2019-10-07 13:35:23 -07:00
Pappenreiter.Thomas
5c373dcc67 hypertreelist demo extended 2019-10-07 13:02:42 +02:00
Robin Dunn
5afa4ed086 Revert part of 7e3844710d 2019-09-19 15:39:42 -07:00
Robin Dunn
86b361d938 Merge pull request #1272 from Metallicow/sizer-fixes
Fix some sizer issues with wxPy4.1
2019-07-08 21:05:12 -07:00
Metallicow
e442736ee3 Fix some sizer issues with wxPy4.1 2019-06-20 19:46:45 -05:00
Rob Rolls
7e3844710d Fix AUI dropdown button not rendering text when icon is wx.NullBitmap 2019-06-18 18:52:44 +01:00
cbeytas
b7d118df0f Add fullscreen option to CustomTreeCtrl Drag/Drop
Feature addition
Add SetDragFullScreen and GetDragFullScreen methods which changes the
way the simplified drag/drop works in the tree. This flag is passed
to the wx.DragImage.BeginDrag() method when it is called.
Also add this option to HyperTreeList.
Modify the CustomTreeCtrl and HyperTreeList demos so it can be tested.
2019-01-07 00:26:28 -05:00
cbeytas
4ed3e536e5 Add sort icon support to HyperTreeList
Feature addition.
Add SetColumnSortIcon() method to HyperTreeList so that a native sort
arrow can be easily shown in the header columns. For some reason does
not work on GTK (won't draw arrow) but works great on Windows/MacOS.

Modify the demo with LIST_COL_CLICK event options so it can be tested.
2019-01-07 00:23:45 -05:00
cbeytas
ac0f578a01 Fix CustomTreeCtrl/HyperTreeList background color
CustomTreeCtrl and HyperTreeList use wx.SYS_COLOUR_LISTBOX for their
default background colors. This defaults to dank Grey on MSW/GTK/MacOS
even though the TreeCtrl and ListCtrl on all three platforms default
to a white background. Use a trick from UltimateListCtrl to take
default colors from wx.ListCtrl.

This can be seen in the demos, except that the CustomTreeCtrl demo
forces its background to wx.WHITE. With these changes forcing the
background color is no longer necessary and allows the controls to
take on the native background color for themes that change it.
2019-01-07 00:12:00 -05:00
cbeytas
8113033d6e Recalculate CustomTreeCtrl on multiline text
In CustomTreeCtrl and HyperTreeList the SetItemText method recalculates
the size of the item row in which the text was changed. If the number
of lines in the text changes the entire tree must be recalculated
as all items below must be shifted to compensate. This change attempts
to recalculate the entire tree only when necessary (when number of
lines change) in order not to slow down existing code that performs a
lot of SetItemText() operations on an unfrozen tree.

Add a "Change Item Text" option to the CustomTreeCtrl and HyperTreeList
demos so that this can be tested. Before this fix, changing the number
of lines of text in an item would leave gaps or create overlaps
between items in the tree.
2019-01-06 23:47:57 -05:00
cbeytas
70464181c9 Fix tree event exception in HyperTreeList demo
The HyperTreeList demo receives events from an embedded TreeCtrl
window which reports a different item type (TreeItemId) than the
HyperTreeList events (TreeListItem). This throws an exception:
    AttributeError: 'TreeItemId' object has no attribute 'GetText'.
Guard against this by only processing events with TreeListItem items.

To reproduce, start the HyperTreeList demo and expand "item 0-a" then
enable it by clicking the radio button. Selecting any item in the
ListCtrl, or expanding/collapsing a tree node will generate exceptions.
2019-01-06 23:31:59 -05:00
cbeytas
2315a7175b Merge item hiding to CustomTreeCtrl
Move item hiding from HyperTreeList to CustomTreeCtrl so that both
trees can have the feature.

Add a HideItemWindows() method to hide windows only for a specific item
and its children. This is much faster than calling HideWindows().

Add context menu options to the CustomTreeCtrl demo so that Hiding
can be tested.
2019-01-06 23:16:20 -05:00
Robin Dunn
e5d24078fd Merge pull request #1087 from cbeytas/master
Fix bugs in CustomTreeCtrl and HyperTreeList
2018-11-30 14:55:02 -08:00
cbeytas
d1361f3d0b Fix bug in HyperTreeList and CustomTreeCtrl demos
Throws ValueError: chr() arg not in range(256) if any special key is
pressed while editing text control.
2018-11-21 15:17:23 -05:00
cbeytas
fb10da6aab Fix typo in CustomTreeCtrl and HyperTreeList demos
Context menu "Change Item Icons" would throw an exception due to typo.
2018-11-21 14:46:06 -05:00
cbeytas
e11848f735 Fix hide items in HypreTreeList
Hiding items was only partially implemented and very buggy.
This feature does not exist in CustomTreeCtrl but I see no reason why
it couldn't be added in the future. This fix requires the arrow key fixes
in order for arrow keys to work reliably in a tree with hidden items.
Hidden items always report they are disabled and not expanded.

Also updates the demo of HyperTreeList to add hide options to context
menu so the feature can be tested.
2018-11-21 14:43:07 -05:00
Metallicow
230bf5d6d3 Optimize All PNGs Nov2018
Since I had to fix a image issue and optimize it. I decided to rerun FileOptimizer 13.30.2393 over all pngs. Small bytes for some that had been optimized before, but this comit covers all pngs that may have been missed in the past. Maybe revisit running them all again in 2 years. Total time to process all pngs: approx 8 hours.
As technology improves this will only get better/faster when downloading, loading in browser, embedded, etc...
2018-11-13 16:08:12 -06:00
Robin Dunn
106f2aa733 Merge pull request #1076 from Metallicow/HyperTreeList-Fix
Fix dc.DrawRectangleRect to dc.DrawRectangle

(cherry picked from commit 3aa4f289e9)
2018-11-08 20:10:13 -08:00
Robin Dunn
addb1906c9 Merge branch 'HelioGuilherme66-40xcustomtreectrl' into wxPy-4.0.x
(cherry picked from commit 32ae30b988)
2018-09-25 15:19:53 -07:00
Robin Dunn
94f8377b77 Merge pull request #979 from RobinD42/fix-issue973
Optimize line drawing in HyperTreeList
(cherry picked from commit b9e2d4d717)
2018-08-29 23:10:00 -07:00