Skip to content

Commit

Permalink
Partial check-in for #57
Browse files Browse the repository at this point in the history
  • Loading branch information
hasii2011 committed Sep 13, 2019
1 parent f6d677b commit cbbc201
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
12 changes: 9 additions & 3 deletions albow/demo/screens/DemoDialogScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,15 @@ def testTitledDialog(cls):
f' by totally disusing and neglecting the militia. -- George Mason]'
)

ttlDlg = TitledDialog(title='Long wrapped message', message=longMsg)
ttlDlg.present()
ttlDlg: TitledDialog = TitledDialog(title='Long wrapped message', message=longMsg)
response = ttlDlg.present()
alert(f'You responded: {response}')

ttlDlg = TitledDialog(title='Chip8 Python', message='Version 0.5, by Humberto A. Sanchez II')
response = ttlDlg.present()
alert(f'You responded: {response}')

ttlDlg: TitledDialog = TitledDialog(title='Chip8 Python', message='Version 0.5, by Humberto A. Sanchez II')
ttlDlg = TitledDialog(title='Three Button', thirdButtTxt='Just Quit', message='Three buttons with custom text')
response = ttlDlg.present()
alert(f'You responded: {response}')

2 changes: 1 addition & 1 deletion albow/dialog/DialogUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
DEFAULT_ASK_RESPONSES = ["OK", "Cancel"]


def alert(theMessage: str, theTitle: str = 'Alert!', theWrapWidth=60, **kwds):
def alert(theMessage: str, theTitle: str = 'Alert!', theWrapWidth=100, **kwds):
"""
Displays a message in a modal dialog, wrapped to the specified width in characters. The dialog can be dismissed by
pressing Return, Enter or Escape.
Expand Down
19 changes: 15 additions & 4 deletions albow/dialog/TitledDialog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

from typing import cast

from logging import Logger
from logging import getLogger

Expand All @@ -25,7 +27,9 @@ class TitledDialog(Dialog):
The number of pixels at which we wrap the input text message
"""

def __init__(self, title: str = 'Default Title', message: str = '', client=None, wrapWidth: int = 100, **kwds):
def __init__(self, title: str = 'Default Title', message: str = '',
okTxt: str = 'Ok', cancelTxt: str = 'Cancel', thirdButtTxt: str = None,
client=None, wrapWidth: int = 100, **kwds):

super().__init__(client=client, width=TitledDialog.TD_SIZE, **kwds)

Expand All @@ -38,10 +42,17 @@ def __init__(self, title: str = 'Default Title', message: str = '', client=None,
margin: int = self.margin
self.logger.info(f'margin: {margin}')

butOk: Button = Button('Ok', action=lambda x='Ok': self.dismiss(x))
butCancel: Button = Button('Cancel', action=lambda x='Cancel': self.dismiss(x))
butOk: Button = Button(okTxt, action=lambda x=okTxt: self.dismiss(x))
butCancel: Button = Button(cancelTxt, action=lambda x=cancelTxt: self.dismiss(x))
butThree: Button = cast(Button, None)
if thirdButtTxt is not None:
butThree = Button(thirdButtTxt, action=lambda x=thirdButtTxt: self.dismiss(x))

if butThree is None:
buttRow: Row = Row([butOk, butCancel], spacing=margin, equalize='w', margin=4)
else:
buttRow: Row = Row([butOk, butCancel, butThree], spacing=margin, equalize='w', margin=4)

buttRow: Row = Row([butOk, butCancel], spacing=margin, equalize='w', margin=4)
botColumn: Column = Column([lblMsg, buttRow], spacing=margin, align='r', margin=4)

mainColumn: Column = Column([dlgTitleBar, botColumn], align='l', expand=1, margin=8, border_width=2, border_color=Theme.CITY_LIGHTS, equalize='w')
Expand Down

0 comments on commit cbbc201

Please sign in to comment.