msg297867 - (view) |
Author: Louie Lu (louielu) * |
Date: 2017-07-07 07:51 |
Add event for KeyRelease-Up and KeyRelease-Down to change sample font.
Current code only changed font when using button-click on listbox.
|
msg298003 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2017-07-09 22:57 |
New changeset bb2bae84d6b29f991b757b46430c3c15c60059e9 by terryjreedy (Louie Lu) in branch 'master':
bpo-30870: IDLE: Change sample font when select by key-up/down (#2617)
https://github.com/python/cpython/commit/bb2bae84d6b29f991b757b46430c3c15c60059e9
|
msg298004 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2017-07-09 23:00 |
If one scrolls with the mousewheel or scrollbar, the selection does not change and the example should not change, and I presume it will not with the patch. If one presses up or down, the selection does change, just as if one clicked, and the example should change. I consider it a bug that it does not. Good catch.
|
msg298006 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2017-07-09 23:26 |
New changeset 7ab334233394070a25344d481c8de1402fa12b29 by terryjreedy in branch '3.6':
[3.6] bpo-30870: IDLE: Change sample font when select by key-up/down (GH-2617) (#2640)
https://github.com/python/cpython/commit/7ab334233394070a25344d481c8de1402fa12b29
|
msg298017 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2017-07-10 01:53 |
We already know that setting StringVar font_name triggers a change to changes. We also know that manually clicking or Up or Down triggers <<ListBoxSelect>>, which sets font_name and redraws the box. The challenge is to do something that will trigger the virtual event. Then we can write a test methods something like
def test_sample(self):
fontlist = configure.fontlist
if fontlist.size():
name0 = fontlist.get(0).lower()
# fontlist.selection_set(0) # or something
print('\n', changes) # temp to testing that changes changes
self.assertEqual(changes['main']['EditorWindow']['font'], name0)
But selection_set does not trigger the event. After fiddling around with various bindings event_generate()s and update()s and update_idletasks(), I concluded, again, that either event_generate or its documentation is badly broken. The only thing I got to work in hours of experiments is this:
import tkinter as tk
root = tk.Tk()
seq = '<ButtonRelease-1>'
root.bind(seq, lambda event: print('generated', event))
root.update_idletasks() # or update()
root.event_generate(seq)
# update here fails
Adding a widget and binding to the widget always failed.
Here is my attempt using Serhiy's simulate_mouse_click. (This goes in test_configdialog.FontTabTest.
def test_sample(self):
fontlist = configure.fontlist
if fontlist.size():
name0 = fontlist.get(0).lower()
fontlist.see(0)
x, y, dx, dy = fontlist.bbox(0)
fontlist.bind('<ButtonRelease-1>', lambda event: print(event))
mouse_click(fontlist, x + dx//2, y + dy//2)
fontlist.update()
print('\n', changes) # temporary, see if changes has anything
self.assertEqual(changes['main']['EditorWindow']['font'], name0)
Serhiy, do you have any idea why I cannot get event_generate to work for a listbox, even with your function? I have tried somewhere close to 20 variations.
|
msg298075 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2017-07-10 18:00 |
Serhiy, I tried tkinter.test.support.simulate_mouse_click to test this patch but it seems not to work. Code at end of previous message. Any idea on how to fix?
|
msg298076 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) * |
Date: 2017-07-10 18:49 |
It isn't my. It was added by Guilherme in r69050.
I'll take a look at code tomorrow.
|
msg298121 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) * |
Date: 2017-07-11 05:32 |
I don't know how to make the testing code working.
|
msg298122 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2017-07-11 05:42 |
My manual test procedure was faulty. Without a unit test, I should have asked for another person to verify.
|
msg298123 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2017-07-11 05:51 |
I believe I read somewhere (SO?) that root.withdraw sometimes affects the effectiveness of event_generate. I will try de-iconifying for just this.
|
msg298124 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2017-07-11 05:58 |
New changeset 5b62b35e6fcba488da2f809965a5f349a4170b02 by terryjreedy in branch 'master':
bpo-30870: IDLE -- fix logic error in eae2537. (#2660)
https://github.com/python/cpython/commit/5b62b35e6fcba488da2f809965a5f349a4170b02
|
msg298127 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2017-07-11 06:16 |
New changeset 953e527763f5af293668135acdf5f0a20c3f6f4f by terryjreedy in branch '3.6':
[3.6] bpo-30870: IDLE -- fix logic error in eae2537. (GH-2660) (#2661)
https://github.com/python/cpython/commit/953e527763f5af293668135acdf5f0a20c3f6f4f
|
msg298130 - (view) |
Author: Louie Lu (louielu) * |
Date: 2017-07-11 06:33 |
It just get wierd, I can't do event_generate with Terry, too.
Attach poc.py that should print out a 'testing', but it didn't.
|
msg298132 - (view) |
Author: Louie Lu (louielu) * |
Date: 2017-07-11 06:49 |
It seem setUpModule will smash out the test, I've add a trust-will-work test inside the test_configdialog.py:
class Test(unittest.TestCase):
def setUp(self):
self.root = tkinter.Tk()
def test_test(self):
self.root.bind('<KeyRelease-Up>', lambda x: print('testing'))
self.root.update()
self.root.event_generate('<KeyRelease-Up>')
This will print out `testing` when commet out setUpModule's `root = Tk()` line. But if this line is running, then the trust-test won't print out `testing`
|
msg298138 - (view) |
Author: Louie Lu (louielu) * |
Date: 2017-07-11 07:08 |
configdialog misuse `self.withdraw` at init, it should be `self.wm_withdraw`, #30900 fix this problem. After that, it should be a success to use event_generate in configdialog unittest with no `self.withdraw`.
|
msg298197 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2017-07-12 06:24 |
The new gui tests passed on Travis (linux), which I strongly suspect does not run gui tests. The generate key test failed on Appveyor (Windows), which means is does run gui tests. It also failed on my machine: generate key release did not work. The generate click test does pass on both Appveyor and my machine, which is progress.
Adding config.fontlist.focus_force() before the key event worked. Louie, I will push that along with other edits tomorrow. I will try exposing the window just for the tests.
|
msg298252 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2017-07-13 00:16 |
Serhiy: question about tkinter.wantobjects.
ConfigDialog sets the font options of label font_sample and text text_highlight_sample with a font tuple such as font=('courier', 12, '').
In the test, I expected retrieval of the font option with
sample_font = dialog.font_sample['font']
hilight_font = dialog.text_highlight_sample['font']
to return tuples, but I get a string: '{courier new} 10 normal'.
I checked and root.wantobjects() is returning the default True. Should not the options be returned as tuples?
|
msg298260 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2017-07-13 05:30 |
PR2666 adds 4% test coverage. 40% left to go. I expect some tests will cover more lines with less code.
I am working on a test for set_font_sample.
|
msg298324 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2017-07-14 00:35 |
New changeset 9b622fb90331f259894e6edb29b5c64b9366491a by terryjreedy (Louie Lu) in branch 'master':
bpo-30870: IDLE: Add configdialog fontlist selection unittest (#2666)
https://github.com/python/cpython/commit/9b622fb90331f259894e6edb29b5c64b9366491a
|
msg298328 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2017-07-14 02:24 |
New changeset 42abf7f9737f78a5da311a42945d781dfcd6c6c0 by terryjreedy in branch '3.6':
[3.6] bpo-30870: IDLE: Add configdialog fontlist selection unittest (GH-2666) (#2701)
https://github.com/python/cpython/commit/42abf7f9737f78a5da311a42945d781dfcd6c6c0
|
msg298760 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2017-07-21 02:23 |
I am closing this as basically complete. I opened #30981 to add and perhaps complete font page tests.
|
|
Date |
User |
Action |
Args |
2022-04-11 14:58:48 | admin | set | github: 75053 |
2017-07-21 02:34:32 | terry.reedy | set | status: open -> closed resolution: fixed stage: test needed -> resolved |
2017-07-21 02:23:21 | terry.reedy | set | messages:
+ msg298760 |
2017-07-14 02:24:58 | terry.reedy | set | messages:
+ msg298328 |
2017-07-14 00:38:34 | terry.reedy | set | pull_requests:
+ pull_request2767 |
2017-07-14 00:35:51 | terry.reedy | set | messages:
+ msg298324 |
2017-07-13 05:30:58 | terry.reedy | set | messages:
+ msg298260 |
2017-07-13 00:16:56 | terry.reedy | set | messages:
+ msg298252 |
2017-07-12 06:24:19 | terry.reedy | set | messages:
+ msg298197 |
2017-07-11 08:49:16 | louielu | set | pull_requests:
+ pull_request2732 |
2017-07-11 07:08:26 | louielu | set | messages:
+ msg298138 |
2017-07-11 06:49:53 | louielu | set | messages:
+ msg298132 |
2017-07-11 06:33:11 | louielu | set | files:
+ tests.py
messages:
+ msg298130 |
2017-07-11 06:16:43 | terry.reedy | set | messages:
+ msg298127 |
2017-07-11 05:59:47 | terry.reedy | set | pull_requests:
+ pull_request2726 |
2017-07-11 05:58:06 | terry.reedy | set | messages:
+ msg298124 |
2017-07-11 05:51:11 | terry.reedy | set | messages:
+ msg298123 |
2017-07-11 05:42:13 | terry.reedy | set | messages:
+ msg298122 |
2017-07-11 05:39:06 | terry.reedy | set | pull_requests:
+ pull_request2725 |
2017-07-11 05:32:11 | serhiy.storchaka | set | messages:
+ msg298121 |
2017-07-10 22:05:15 | terry.reedy | link | issue24776 dependencies |
2017-07-10 18:49:22 | serhiy.storchaka | set | messages:
+ msg298076 |
2017-07-10 18:47:55 | terry.reedy | link | issue30780 dependencies |
2017-07-10 18:00:32 | terry.reedy | set | nosy:
+ serhiy.storchaka
messages:
+ msg298075 stage: patch review -> test needed |
2017-07-10 01:53:56 | terry.reedy | set | messages:
+ msg298017 |
2017-07-09 23:26:34 | terry.reedy | set | messages:
+ msg298006 |
2017-07-09 23:08:04 | terry.reedy | set | pull_requests:
+ pull_request2705 |
2017-07-09 23:00:45 | terry.reedy | set | messages:
+ msg298004 |
2017-07-09 22:57:21 | terry.reedy | set | messages:
+ msg298003 |
2017-07-08 19:06:16 | terry.reedy | set | stage: patch review type: enhancement versions:
+ Python 3.6 |
2017-07-07 07:52:22 | louielu | set | pull_requests:
+ pull_request2683 |
2017-07-07 07:51:29 | louielu | create | |