-
-
Notifications
You must be signed in to change notification settings - Fork 412
Update gui.py #218
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Open
saddy001
wants to merge
12
commits into
rawpython:master
Choose a base branch
from
saddy001:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Update gui.py #218
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c9f1206
Update gui.py
saddy001 010ff9b
text_align keyword for TableEditableItem
saddy001 96abbdf
text_align keyword for TableEditableItem
saddy001 379d840
add text_style for TableEditableItem
saddy001 3c5cb94
tree_open as explicit keyword on TreeItem
saddy001 ec64320
margin overrides margin-left/top etc.
saddy001 b7778af
allow hint kwarg also for TableEditableItem (#1)
saddy001 9ab1389
Update gui.py
saddy001 fccb0f7
Update gui.py
saddy001 871b5d0
Add cancel_button kwarg for GenericDialog
saddy001 03a54f4
Merge pull request #2 from saddy001/saddy001-generic-cancel_button
saddy001 1dd886a
Allow tooltip_title for ListItem
saddy001 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -373,7 +373,7 @@ class Widget(Tag): | |
EVENT_ONUPDATE = 'onupdate' | ||
|
||
@decorate_constructor_parameter_types([]) | ||
def __init__(self, **kwargs): | ||
def __init__(self, margin='0px', **kwargs): | ||
""" | ||
Args: | ||
width (int, str): An optional width for the widget (es. width=10 or width='10px' or width='10%'). | ||
|
@@ -390,7 +390,9 @@ def __init__(self, **kwargs): | |
self.eventManager = _EventManager(self) | ||
self.oldRootWidget = None # used when hiding the widget | ||
|
||
self.style['margin'] = kwargs.get('margin', '0px') | ||
if margin: | ||
self.style['margin'] = margin | ||
|
||
self.set_layout_orientation(kwargs.get('layout_orientation', Widget.LAYOUT_VERTICAL)) | ||
self.set_size(kwargs.get('width'), kwargs.get('height')) | ||
self.set_style(kwargs.pop('style', None)) | ||
|
@@ -1306,7 +1308,7 @@ class GenericDialog(Widget): | |
EVENT_ONCANCEL = 'cancel_dialog' | ||
|
||
@decorate_constructor_parameter_types([str, str]) | ||
def __init__(self, title='', message='', **kwargs): | ||
def __init__(self, title='', message='', cancel_button=True, **kwargs): | ||
""" | ||
Args: | ||
title (str): The title of the dialog. | ||
|
@@ -1315,7 +1317,7 @@ def __init__(self, title='', message='', **kwargs): | |
""" | ||
super(GenericDialog, self).__init__(**kwargs) | ||
self.set_layout_orientation(Widget.LAYOUT_VERTICAL) | ||
self.style.update({'display':'block', 'overflow':'auto', 'margin':'0px auto'}) | ||
self.style.update({'display':'block', 'overflow':'auto', 'margin':'8px auto', 'padding': '8px'}) | ||
|
||
if len(title) > 0: | ||
t = Label(title) | ||
|
@@ -1333,22 +1335,25 @@ def __init__(self, title='', message='', **kwargs): | |
self.conf = Button('Ok') | ||
self.conf.set_size(100, 30) | ||
self.conf.style['margin'] = '3px' | ||
self.cancel = Button('Cancel') | ||
self.cancel.set_size(100, 30) | ||
self.cancel.style['margin'] = '3px' | ||
hlay = Widget(height=35) | ||
hlay.style['display'] = 'block' | ||
hlay.style['overflow'] = 'visible' | ||
hlay.append(self.conf) | ||
hlay.append(self.cancel) | ||
self.conf.style['float'] = 'right' | ||
self.cancel.style['float'] = 'right' | ||
|
||
if cancel_button: | ||
self.cancel = Button('Cancel') | ||
self.cancel.set_size(100, 30) | ||
self.cancel.style['margin'] = '3px' | ||
self.cancel.style['float'] = 'right' | ||
self.cancel.attributes[self.EVENT_ONCLICK] = "sendCallback('%s','%s');" % ( | ||
self.identifier, self.EVENT_ONCANCEL) | ||
hlay.append(self.cancel) | ||
|
||
self.append(self.container) | ||
self.append(hlay) | ||
|
||
self.conf.attributes[self.EVENT_ONCLICK] = "sendCallback('%s','%s');" % (self.identifier, self.EVENT_ONCONFIRM) | ||
self.cancel.attributes[self.EVENT_ONCLICK] = "sendCallback('%s','%s');" % (self.identifier, self.EVENT_ONCANCEL) | ||
|
||
self.inputs = {} | ||
|
||
|
@@ -1667,7 +1672,7 @@ class ListItem(Widget, _MixinTextualWidget): | |
""" | ||
|
||
@decorate_constructor_parameter_types([str]) | ||
def __init__(self, text, **kwargs): | ||
def __init__(self, text, tooltip_title='', **kwargs): | ||
""" | ||
Args: | ||
text (str, unicode): The textual content of the ListItem. | ||
|
@@ -1677,6 +1682,10 @@ def __init__(self, text, **kwargs): | |
self.type = 'li' | ||
|
||
self.attributes[self.EVENT_ONCLICK] = '' | ||
|
||
if tooltip_title: | ||
self.attributes['title'] = tooltip_title | ||
|
||
self.set_text(text) | ||
|
||
def get_value(self): | ||
|
@@ -2119,15 +2128,15 @@ class TableEditableItem(Widget, _MixinTextualWidget): | |
"""item widget for the TableRow.""" | ||
|
||
@decorate_constructor_parameter_types([str]) | ||
def __init__(self, text='', **kwargs): | ||
def __init__(self, text='', text_style={}, **kwargs): | ||
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. mutable functions args (dict in signature) are not a good idea 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. If you have your hands already on this, could you change it to None and assign |
||
""" | ||
Args: | ||
text (str): | ||
kwargs: See Widget.__init__() | ||
""" | ||
super(TableEditableItem, self).__init__(**kwargs) | ||
self.type = 'td' | ||
self.editInput = TextInput() | ||
self.editInput = TextInput(style=text_style, **kwargs) | ||
self.append(self.editInput) | ||
self.editInput.set_on_change_listener(self.onchange) | ||
self.get_text = self.editInput.get_text | ||
|
@@ -2720,7 +2729,7 @@ class TreeItem(Widget, _MixinTextualWidget): | |
"""TreeItem widget can contain other TreeItem.""" | ||
|
||
@decorate_constructor_parameter_types([str]) | ||
def __init__(self, text, **kwargs): | ||
def __init__(self, text, tree_open=False, **kwargs): | ||
""" | ||
Args: | ||
text (str): | ||
|
@@ -2733,8 +2742,8 @@ def __init__(self, text, **kwargs): | |
"sendCallback('%s','%s');" \ | ||
"event.stopPropagation();event.preventDefault();" % (self.identifier, self.EVENT_ONCLICK) | ||
self.set_text(text) | ||
self.treeopen = False | ||
self.attributes['treeopen'] = 'false' | ||
self.treeopen = tree_open | ||
self.attributes['treeopen'] = str(tree_open).lower() | ||
self.attributes['has-subtree'] = 'false' | ||
|
||
def append(self, value, key=''): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A more proficient way to do styling would be to use css stylesheet. Otherwise we should add a style parameter for each widget in a container, like TableItem in Tables, ListItem in ListView and so on... Doesn't it?
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 don't know how to use separate stylesheets, because at the moment, there is no documentation about it ;-)
If it means that the whole original stylesheet has to be copied, I don't think it's a good idea...