-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
MEP27 Decouple pyplot from backends (refactoring Gcf out of backend code) #4143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
24caf2b
2b05d38
f4fc354
0b31e3a
6fb452e
0a868a2
61ba2b4
f0eb84c
8fe9cd7
494e5f1
ed16178
21b8f58
cf42e3b
f027b16
24b7b73
bc99129
7f7f05e
713abcb
80adaaf
4e5f69d
160ef57
b6d6acc
ecd5038
f8e83fe
c53b79a
34c6b12
8a4268a
44df199
860a8ed
c44e744
2fe9215
3b434ef
490629f
8eb987b
224a4f3
cdbd51b
50e3719
85be519
7edaf5a
8e6e252
72575cb
4a78246
e300707
ee76451
6f0c7ab
ae9bf5b
fb004e0
1d2095b
24e43b3
208c3be
a44ebd9
f8f9cf2
0e09a54
a38b6d7
64f0c61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -385,7 +385,7 @@ def stop_event_loop(self): | |
FigureCanvasBase.stop_event_loop_default(self) | ||
stop_event_loop.__doc__=FigureCanvasBase.stop_event_loop_default.__doc__ | ||
|
||
class WindowGTK3(WindowBase, Gtk.Window): | ||
class Window(WindowBase, Gtk.Window): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't keep the name something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally, I don't really see what difference it makes apart from taking up extra hard drive and memory space. At the moment we have I don't mind renaming it, I just don't see any need for it... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kind of agree with you, but in that case, why don't we remove all the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 On making the GUI specific classes have the framework name in them and doing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess "bad" beats "ugly" (ugly in terms of a list of housekeeping aliases at end of each file. I can't imagine how it could get bad, (on the other hand I found debugging that transform logic a nightmare with multiple layers of transforms to go through and understand what they what they were doing and why they were failing), so meh. |
||
def __init__(self, title): | ||
WindowBase.__init__(self, title) | ||
Gtk.Window.__init__(self) | ||
|
@@ -403,22 +403,35 @@ def __init__(self, title): | |
# better way is - JDH | ||
verbose.report('Could not load matplotlib icon: %s' % sys.exc_info()[1]) | ||
|
||
self.vbox = Gtk.Box() | ||
self.vbox.set_property('orientation', Gtk.Orientation.VERTICAL) | ||
self.add(self.vbox) | ||
self.vbox.show() | ||
self._layout = {} | ||
self._setup_box('_outer', Gtk.Orientation.VERTICAL, False, None) | ||
self._setup_box('north', Gtk.Orientation.VERTICAL, False, '_outer') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find it a little bit strange the nomenclature There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Meh, the first programming language I learnt, Java, used this nomenclature, so does jquery (for websites, i.e. I don't mind which nomenclature, just so long as we stay clear of Parkinson's law 😉. Also just found this (you don't need to look at it, but just leaving it here for future reference) which should help with Qt http://ftp.ics.uci.edu/pub/centos0/ics-custom-build/BUILD/PyQt-x11-gpl-4.7.2/examples/layouts/borderlayout.py There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, it's only me, don't worry, leave it like that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of course I only gave examples of where this nomenclature gets used, so interpret the above as having a strong confirmation bias, but I guess you don't mind either way. |
||
self._setup_box('_middle', Gtk.Orientation.HORIZONTAL, True, '_outer') | ||
self._setup_box('south', Gtk.Orientation.VERTICAL, False, '_outer') | ||
|
||
self._setup_box('west', Gtk.Orientation.HORIZONTAL, False, '_middle') | ||
self._setup_box('center', Gtk.Orientation.VERTICAL, True, '_middle') | ||
self._setup_box('east', Gtk.Orientation.HORIZONTAL, False, '_middle') | ||
|
||
self.add(self._layout['_outer']) | ||
|
||
self.connect('destroy', self.destroy_event) | ||
self.connect('delete_event', self.destroy_event) | ||
|
||
def add_element_to_window(self, element, expand, fill, pad, side='bottom'): | ||
def _setup_box(self, name, orientation, grow, parent): | ||
self._layout[name] = Gtk.Box(orientation=orientation) | ||
if parent: | ||
self._layout[parent].pack_start(self._layout[name], grow, grow, 0) | ||
self._layout[name].show() | ||
|
||
def add_element_to_window(self, element, expand, fill, pad, place): | ||
element.show() | ||
if side == 'top': | ||
self.vbox.pack_start(element, expand, fill, pad) | ||
elif side == 'bottom': | ||
self.vbox.pack_end(element, expand, fill, pad) | ||
if place in ['north', 'west', 'center']: | ||
self._layout[place].pack_start(element, expand, fill, pad) | ||
elif place in ['south', 'east']: | ||
self._layout[place].pack_end(element, expand, fill, pad) | ||
else: | ||
raise KeyError('Unknown value for side, %s' % side) | ||
raise KeyError('Unknown value for place, %s' % place) | ||
size_request = element.size_request() | ||
return size_request.height | ||
|
||
|
@@ -430,7 +443,6 @@ def show(self): | |
Gtk.Window.show(self) | ||
|
||
def destroy(self): | ||
self.vbox.destroy() | ||
Gtk.Window.destroy(self) | ||
|
||
def set_fullscreen(self, fullscreen): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, but, as you said in the comment, how many of our current backends (GUI backends) support all the options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, I think I want to get rid of
pad
as I think we always want that as 0? Also eitherfill
orexpand
as I feel we will always have them both asTrue
or both asFalse
, and feels like extra work to research if methods exist to do it for the different backends.Also what do you think about renaming this method, to just
add_element
oradd_widget
, I think_to_window
becomes extraneous, as it gets called on theWindow
class, but I can't decide between the two names...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change it to
add_widget
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these native GUI widgets or mpl widgets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the GUI widgets that are going to be defined for each backend, so far
Window
,Toolbar
,Message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OceanWolf yes I mean
Statusbar
, but you have to removeNavigationToolbar2
that I believe it's not compatible with this approachThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fariza With which part of this approach? It works fine for me...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that I am not sure
NavigationToolbar2
will work in all the backends, as I am not sure they all return just the widget. But it will be matter of testing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, well I have gone through all of the GUI backends apart from the Mac specific ones 😒 and GTK2, prior to MEP22 going to master, and got them all to work.
Though if I remember correctly I did have to do this on one them:
but that doesn't matter as we can do that kind of thing on the specific backend 😉.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, so how about
add_element(self, element, expand, place)
?