Skip to content

Added acceptance of string anchors/sides for TkInter such as "w" and "top" #158

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions problem_db/gui1.tut/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,19 @@ def _analyse(self):
'pack (in {})'.format(pack.function_name)
)
elif pack.keywords['side'] != 'tk.LEFT':
self.add_error(
'You should be packing to the LEFT (got {} instead '
'in {})'.format(
pack.keywords['side'], pack.function_name
if pack.keywords['side'].lower() == 'left':
self.error(
'You appear to be using \'{}\' as your value for'
'side. (in {}). Please use tk.LEFT'.format(
pack.keywords['side'], pack.function_name)
)
else:
self.add_error(
'You should be packing to the LEFT (got {} instead '
'in {})'.format(
pack.keywords['side'], pack.function_name
)
)
)
elif len(pack.keywords) > 1:
self.add_error(
'You only need to provide side as an argument to '
Expand Down
32 changes: 23 additions & 9 deletions problem_db/gui2.tut/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,35 @@ def _analyse(self):
'pack (in {})'.format(pack.function_name)
)
elif pack.keywords['side'] != 'tk.TOP':
self.add_error(
'You appear to be using the wrong value for side '
'(in {})'.format(pack.function_name)
)
if pack.keywords['side'].lower() == 'top':
self.error(
'You appear to be using \'{}\' as your value for'
'side. (in {}). Please use tk.TOP'.format(
pack.keywords['side'], pack.function_name)
)
else:
self.add_error(
'You appear to be using the wrong value for side '
'(in {})'.format(pack.function_name)
)

if 'anchor' not in pack.keywords:
self.add_error(
'You need to make sure that the buttons appear on top '
'of each other on the left of the frame'
)
elif pack.keywords['anchor'] != 'tk.W':
self.add_error(
'You appear to be using the wrong value for anchor '
'(in {})'.format(pack.function_name)
)
if pack.keywords['anchor'].lower() == "w":
self.error(
'You appear to be using \'{}\' as your anchor'
'value. (in {}). Please use tk.W'.format(
pack.keywords['anchor'], pack.function_name)
)
else:
self.add_error(
'You appear to be using the wrong value for anchor'
' (in {})'.format(pack.function_name)
)

# first, make sure that they're packing twice
if len(pack_calls) != 2:
Expand Down Expand Up @@ -162,4 +176,4 @@ def _analyse(self):
)


ANALYSER = Analyser(CodeVisitor)
ANALYSER = Analyser(CodeVisitor)
18 changes: 13 additions & 5 deletions problem_db/gui3.tut/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,20 @@ def _analyse(self):
'pack (in {})'.format(pack.function_name)
)
elif pack.keywords['side'] != 'tk.{}'.format(side):
self.add_error(
'You should be packing to the {} (got {} instead '
'in {})'.format(
side, pack.keywords['side'], pack.function_name
if pack.keywords['side'].lower() == side.lower():
self.error(
'You appear to be using \'{}\' as your value for'
'side. (in {}). Please use tk.{}'.format(
pack.keywords['side'], pack.function_name,
side)
)
else:
self.add_error(
'You should be packing to the {} (got {} instead '
'in {})'.format(
side, pack.keywords['side'], pack.function_name
)
)
)

if 'expand' not in pack.keywords:
self.add_error(
Expand Down