Tkinter Button Command Taking Only Newest Reference In Callback Parameter
Greetings, I'm doing this project: https://github.com/Abdur-rahmaanJ/cmdlaunch/blob/master/cmdlaunch/cmdlaunch.py Everything works fine, except for one thing. On line 60, the button is taking an object in it's command parameter If you run the file, you'll see that all the different names are written on the gui just the callback is takest the newest icon object for all three buttons I know just a reference issue but it's been **bugging** me. Thanks All -- Abdur-Rahmaan Janhangeer Mauritius -- https://mail.python.org/mailman/listinfo/python-list
Re: Images on Dynamically Generated Buttons Glitch
Did it but that's €=€$/€*#£4×53@ Abdur-Rahmaan Janhangeer Mauritius -- https://mail.python.org/mailman/listinfo/python-list
Re: Images on Dynamically Generated Buttons Glitch
On 2019-07-08 03:05, Abdur-Rahmaan Janhangeer wrote: You mean we should create the image variables aside like one for each button? XD. Thanks! You need to ensure that there's a reference somewhere to every image that you're displaying, whether it's on a button or some other widget, because tkinter itself doesn't keep a reference to the image. Sometimes the most convenient way is to put them in a list, but just pick what makes the most sense for your use case. -- https://mail.python.org/mailman/listinfo/python-list
Re: Images on Dynamically Generated Buttons Glitch
You mean we should create the image variables aside like one for each button? XD. Thanks! Abdur-Rahmaan Janhangeer Mauritius -- https://mail.python.org/mailman/listinfo/python-list
Re: Images on Dynamically Generated Buttons Glitch
On 2019-07-07 19:28, Abdur-Rahmaan Janhangeer wrote: Greetings, i have this snippet: --- import json import os from tkinter import * from tkinter.ttk import * root = Tk() jload = json.load buttons = list() programs = os.listdir('programs') for i, program in enumerate(programs): jsonpath = 'programs/{}/cmdlaunch.json'.format(program) info = jload(open(jsonpath)) photo = PhotoImage(file = 'icons/'+info['icon']) photoimage = photo.subsample(3, 3) buttons.append(Button(root, text = 'Click Me !', image = photoimage, compound = LEFT)) buttons[-1].pack() root.mainloop() --- All buttons are appearing but only the last button is displaying the image, any idea? You need to keep a reference to the image that you passed when creating the button; tkinter itself doesn't keep a reference to it: import json import os from tkinter import * from tkinter.ttk import * root = Tk() jload = json.load buttons = list() images = [] programs = os.listdir('programs') for i, program in enumerate(programs): jsonpath = 'programs/{}/cmdlaunch.json'.format(program) info = jload(open(jsonpath)) photo = PhotoImage(file = 'icons/'+info['icon']) photoimage = photo.subsample(3, 3) buttons.append(Button(root, text = 'Click Me !', image = photoimage, compound = LEFT)) buttons[-1].pack() images.append(photoimage) root.mainloop() In your code, 'photoimage' still refers to the last image, but there are no references to the previous images, so they're discarded. (Why is tkinter like that? Who knows! :-)) -- https://mail.python.org/mailman/listinfo/python-list
Images on Dynamically Generated Buttons Glitch
Greetings, i have this snippet: --- import json import os from tkinter import * from tkinter.ttk import * root = Tk() jload = json.load buttons = list() programs = os.listdir('programs') for i, program in enumerate(programs): jsonpath = 'programs/{}/cmdlaunch.json'.format(program) info = jload(open(jsonpath)) photo = PhotoImage(file = 'icons/'+info['icon']) photoimage = photo.subsample(3, 3) buttons.append(Button(root, text = 'Click Me !', image = photoimage, compound = LEFT)) buttons[-1].pack() root.mainloop() --- All buttons are appearing but only the last button is displaying the image, any idea? -- Abdur-Rahmaan Janhangeer http://www.pythonmembers.club Mauritius -- https://mail.python.org/mailman/listinfo/python-list
Re: how to setup for localhost:8000
On Sun, 07 Jul 2019 16:57:12 +, nabru wrote: > jaymoyer44 [jaymoye...@gmail.com] wrote: > >> On Thursday, April 14, 2016 at 1:47:03 PM UTC-4, wrh...@gmail.com >> wrote: >>> Hi, >>> >>> I am working on window 7 and Python 3.5 to setup a localhost:8000 but >>> it did not get through as shown below: >>> > python -m http.server >>> Serving HTTP on 0.0.0.0 port 8000 ... >>> >>> But it did not show the results. >>> >>> Can someone help me how to setup the localhost? >>> >>> Thanks, >>> Wen-Ruey > > If it says 'serving HTTP...' try visiting localhost:8000 on your browser > to see what happens. failing that try showing your code so that we do not have to be psychic! -- Nirvana? That's the place where the powers that be and their friends hang out. -- Zonker Harris -- https://mail.python.org/mailman/listinfo/python-list
Re: how to setup for localhost:8000
jaymoyer44 [jaymoye...@gmail.com] wrote: > On Thursday, April 14, 2016 at 1:47:03 PM UTC-4, wrh...@gmail.com wrote: >> Hi, >> >> I am working on window 7 and Python 3.5 to setup a localhost:8000 but >> it did not get through as shown below: >> > python -m http.server >> Serving HTTP on 0.0.0.0 port 8000 ... >> >> But it did not show the results. >> >> Can someone help me how to setup the localhost? >> >> Thanks, >> Wen-Ruey If it says 'serving HTTP...' try visiting localhost:8000 on your browser to see what happens. -- ~nabru -- https://mail.python.org/mailman/listinfo/python-list
Re: What's wrong on using Popen's communicate method?
eryk sun於 2019年7月7日星期日 UTC+8下午3時51分57秒寫道: > On 7/6/19, jf...@ms4.hinet.net wrote: > > > > I turn off the anti-virus and tried v3.6.8, get the same result. Usually the > > anti-virus program will warn me if something was blocked. > > In case the executable is corrupt, clear your browser cache and > download the 32-bit version again: > > https://www.python.org/ftp/python/3.6.8/python-3.6.8.exe > > Try to run the installer from an elevated command prompt. If it fails > to run, check again for log files in your %TEMP% directory, which > typically expands to "C:\Users\\AppData\Local\Temp". > > If the installer is still not running -- not even enough to create a > single log file -- then apparently something is configured incorrectly > or missing on your computer that's causing it to fail hard. I'd have > to run it under a debugger to find the cause. > > Anyway, if you're stuck with ancient 3.4, you can at least install > "pywin32-221.win32-py3.4.exe" from the old SourceForge repo: > > https://sourceforge.net/projects/pywin32/files/pywin32/Build%20221 I had overlooked your suggestion of installing it under elevated command prompt. At the last moment I was noticed and gave it a try. Guess what? I run Python-3.6.8.exe successfully and installed it. A real surprise! Thank you for everything you had done to help. --Jach -- https://mail.python.org/mailman/listinfo/python-list
Re: how to setup for localhost:8000
On Thursday, April 14, 2016 at 1:47:03 PM UTC-4, wrh...@gmail.com wrote: > Hi, > > I am working on window 7 and Python 3.5 to setup a localhost:8000 but it did > not get through as shown below: > > python -m http.server > Serving HTTP on 0.0.0.0 port 8000 ... > > But it did not show the results. > > Can someone help me how to setup the localhost? > > Thanks, > Wen-Ruey On Thursday, April 14, 2016 at 1:47:03 PM UTC-4, wrh...@gmail.com wrote: > Hi, > > I am working on window 7 and Python 3.5 to setup a localhost:8000 but it did > not get through as shown below: > > python -m http.server > Serving HTTP on 0.0.0.0 port 8000 ... > > But it did not show the results. > > Can someone help me how to setup the localhost? > > Thanks, > Wen-Ruey -- https://mail.python.org/mailman/listinfo/python-list
Re: how to setup for localhost:8000
On Thursday, April 14, 2016 at 1:47:03 PM UTC-4, wrh...@gmail.com wrote: > Hi, > > I am working on window 7 and Python 3.5 to setup a localhost:8000 but it did > not get through as shown below: > > python -m http.server > Serving HTTP on 0.0.0.0 port 8000 ... > > But it did not show the results. > > Can someone help me how to setup the localhost? > > Thanks, > Wen-Ruey -- https://mail.python.org/mailman/listinfo/python-list
Re: What's wrong on using Popen's communicate method?
eryk sun於 2019年7月7日星期日 UTC+8下午3時51分57秒寫道: > On 7/6/19, jf...@ms4.hinet.net wrote: > > > > I turn off the anti-virus and tried v3.6.8, get the same result. Usually the > > anti-virus program will warn me if something was blocked. > > In case the executable is corrupt, clear your browser cache and > download the 32-bit version again: I have its MD5 checked after each download. > https://www.python.org/ftp/python/3.6.8/python-3.6.8.exe > > Try to run the installer from an elevated command prompt. If it fails > to run, check again for log files in your %TEMP% directory, which > typically expands to "C:\Users\\AppData\Local\Temp". > > If the installer is still not running -- not even enough to create a > single log file -- then apparently something is configured incorrectly > or missing on your computer that's causing it to fail hard. I'd have > to run it under a debugger to find the cause. It's very possible there is some problem in my system. A few months ago suddenly I can't login to my email account through ThunderBird. Now I have to remove my password from its settings and manually type-in every time when I log in. Using a debugger is a big burden to me because I am not familiar with the internal of Windows well. > Anyway, if you're stuck with ancient 3.4, you can at least install > "pywin32-221.win32-py3.4.exe" from the old SourceForge repo: > > https://sourceforge.net/projects/pywin32/files/pywin32/Build%20221 Thank you for the link. I will try it later and hope it will run:-) --Jach -- https://mail.python.org/mailman/listinfo/python-list
Re: What's wrong on using Popen's communicate method?
On 7/6/19, jf...@ms4.hinet.net wrote: > > I turn off the anti-virus and tried v3.6.8, get the same result. Usually the > anti-virus program will warn me if something was blocked. In case the executable is corrupt, clear your browser cache and download the 32-bit version again: https://www.python.org/ftp/python/3.6.8/python-3.6.8.exe Try to run the installer from an elevated command prompt. If it fails to run, check again for log files in your %TEMP% directory, which typically expands to "C:\Users\\AppData\Local\Temp". If the installer is still not running -- not even enough to create a single log file -- then apparently something is configured incorrectly or missing on your computer that's causing it to fail hard. I'd have to run it under a debugger to find the cause. Anyway, if you're stuck with ancient 3.4, you can at least install "pywin32-221.win32-py3.4.exe" from the old SourceForge repo: https://sourceforge.net/projects/pywin32/files/pywin32/Build%20221 -- https://mail.python.org/mailman/listinfo/python-list