Conversation
sredmond
left a comment
There was a problem hiding this comment.
Thank you for submitting a PR! Can you comment on the purpose of the new attribute label?
Regarding the other questions:
GTextFields show up inRegion.NORTHfrom the lack of lazy (Tk) instantiation throughout all of backend_tk.py (i.e. Tk constructors are called at Python object initialization time, not when the object is added for the first time).- There is no
GWindow.clear_canvaswritten yet, although I'd welcome one! Forwindow.clear(), what is the error? I have a feeling it's the ordering between clearing the window and clearing the contents of the topGCompound, but I wouldn't be sure.
campy/gui/ginteractors.py
Outdated
| """ | ||
| super().__init__(self) | ||
| self._width = width | ||
| self.label = label |
There was a problem hiding this comment.
If students shouldn't know about / stumble upon modifying this variable, it can be marked as self._label (indicating that it's intended as a 'private' variable).
| return | ||
|
|
||
| win = self._windows[-1] | ||
| gtextfield._tkin = win |
There was a problem hiding this comment.
Small typo?
| gtextfield._tkin = win | |
| gtextfield._tkwin = win |
| return gtextfield._tkobj.get() | ||
|
|
||
| def gtextfield_set_enter_event(self, gtextfield, fn): | ||
| gtextfield._tkobj.bind("<Return>", lambda event: fn(event)) |
There was a problem hiding this comment.
This call exposes the Tk event to the student function passed to onenter, and should probably be wrapped up into a GActionEvent eventually, although I'm not sure that the event pipeline is ready for that yet, so this is an acceptable workaround!
campy/gui/ginteractors.py
Outdated
|
|
||
| def onenter(self, fn): | ||
| """Set event handler for return key""" | ||
| _platform.Platform().gtextfield_set_enter_event(self, fn) |
There was a problem hiding this comment.
Add this function also to backend_base.py (so that other backends know that they would have to implement it)
campy/gui/ginteractors.py
Outdated
|
|
||
| def __str__(self): | ||
| return "GTextField(text={}, width={})".format(self.text, self.width) | ||
| return "GTextField(text={}, label={}, width={})".format(self.text, self.label, self.width) |
There was a problem hiding this comment.
What is the difference between text and label on this object? It looks like label is being used as a tk-based string tag for the object in gtextfield_constructor (for eventual events, perhaps?). If they are the same, these attributes should be merged into one.
… to the right for this to work...
|
Here's the window.clear() error: |
|
Resolved window.clear() error above but not sure if maybe there's a cleaner solution |
Changes made:
Decisions about general conventions/structure:
Currently working for NameSurfer (program not included in PR).
---STILL IN PROGRESS---
Need to fix:
Nice to have: