Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue30870

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:IDLE: configdialog/fonts: change font when select by key up/down
Type:enhancementStage:resolved
Components:IDLEVersions:Python 3.7, Python 3.6
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: terry.reedyNosy List: louielu, serhiy.storchaka, terry.reedy
Priority:normalKeywords:

Created on2017-07-07 07:51 bylouielu, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
tests.pylouielu,2017-07-11 06:33
Pull Requests
URLStatusLinkedEdit
PR 2617mergedlouielu,2017-07-07 07:52
PR 2640mergedterry.reedy,2017-07-09 23:08
PR 2660mergedterry.reedy,2017-07-11 05:39
PR 2661mergedterry.reedy,2017-07-11 05:59
PR 2666mergedlouielu,2017-07-11 08:49
PR 2701mergedterry.reedy,2017-07-14 00:38
Messages (21)
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)*(Python committer)Date: 2017-07-09 22:57
New changesetbb2bae84d6b29f991b757b46430c3c15c60059e9 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)*(Python committer)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)*(Python committer)Date: 2017-07-09 23:26
New changeset7ab334233394070a25344d481c8de1402fa12b29 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)*(Python committer)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 tkroot = tk.Tk()seq = '<ButtonRelease-1>'root.bind(seq, lambda event: print('generated', event))root.update_idletasks()  # or update()root.event_generate(seq)# update here failsAdding 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)*(Python committer)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)*(Python committer)Date: 2017-07-10 18:49
It isn't my. It was added by Guilherme inr69050.I'll take a look at code tomorrow.
msg298121 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)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)*(Python committer)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)*(Python committer)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)*(Python committer)Date: 2017-07-11 05:58
New changeset5b62b35e6fcba488da2f809965a5f349a4170b02 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)*(Python committer)Date: 2017-07-11 06:16
New changeset953e527763f5af293668135acdf5f0a20c3f6f4f 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)*(Python committer)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)*(Python committer)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)*(Python committer)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)*(Python committer)Date: 2017-07-14 00:35
New changeset9b622fb90331f259894e6edb29b5c64b9366491a 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)*(Python committer)Date: 2017-07-14 02:24
New changeset42abf7f9737f78a5da311a42945d781dfcd6c6c0 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)*(Python committer)Date: 2017-07-21 02:23
I am closing this as basically complete.  I opened#30981 to add and perhaps complete font page tests.
History
DateUserActionArgs
2022-04-11 14:58:48adminsetgithub: 75053
2017-07-21 02:34:32terry.reedysetstatus: open -> closed
resolution: fixed
stage: test needed -> resolved
2017-07-21 02:23:21terry.reedysetmessages: +msg298760
2017-07-14 02:24:58terry.reedysetmessages: +msg298328
2017-07-14 00:38:34terry.reedysetpull_requests: +pull_request2767
2017-07-14 00:35:51terry.reedysetmessages: +msg298324
2017-07-13 05:30:58terry.reedysetmessages: +msg298260
2017-07-13 00:16:56terry.reedysetmessages: +msg298252
2017-07-12 06:24:19terry.reedysetmessages: +msg298197
2017-07-11 08:49:16louielusetpull_requests: +pull_request2732
2017-07-11 07:08:26louielusetmessages: +msg298138
2017-07-11 06:49:53louielusetmessages: +msg298132
2017-07-11 06:33:11louielusetfiles: +tests.py

messages: +msg298130
2017-07-11 06:16:43terry.reedysetmessages: +msg298127
2017-07-11 05:59:47terry.reedysetpull_requests: +pull_request2726
2017-07-11 05:58:06terry.reedysetmessages: +msg298124
2017-07-11 05:51:11terry.reedysetmessages: +msg298123
2017-07-11 05:42:13terry.reedysetmessages: +msg298122
2017-07-11 05:39:06terry.reedysetpull_requests: +pull_request2725
2017-07-11 05:32:11serhiy.storchakasetmessages: +msg298121
2017-07-10 22:05:15terry.reedylinkissue24776 dependencies
2017-07-10 18:49:22serhiy.storchakasetmessages: +msg298076
2017-07-10 18:47:55terry.reedylinkissue30780 dependencies
2017-07-10 18:00:32terry.reedysetnosy: +serhiy.storchaka

messages: +msg298075
stage: patch review -> test needed
2017-07-10 01:53:56terry.reedysetmessages: +msg298017
2017-07-09 23:26:34terry.reedysetmessages: +msg298006
2017-07-09 23:08:04terry.reedysetpull_requests: +pull_request2705
2017-07-09 23:00:45terry.reedysetmessages: +msg298004
2017-07-09 22:57:21terry.reedysetmessages: +msg298003
2017-07-08 19:06:16terry.reedysetstage: patch review
type: enhancement
versions: + Python 3.6
2017-07-07 07:52:22louielusetpull_requests: +pull_request2683
2017-07-07 07:51:29louielucreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp