Re: tkinter: variable width widgets in a grid?
On 24/02/2019 17:09, Rich Shepard wrote: > When placing widgets (e.g., Entry, Spinbox) in a grid layout can a length > (visible width) be specified? For example, a telephone extension is a > shorter > string than the number itself. > > What's a good resource (other than this mail list) for such questions? > > TIA, > > Rich Hi Not sure if this is helpful. I wrote a small application in python-tk, and you can indeed do this #define boxes namebx = Text(window, height=1, width=20) officebx = Text(window, height=1, width=20) With the main project (parts are work in progress) here https://github.com/zleap/AboutMe hope this helps regards Paul -- https://mail.python.org/mailman/listinfo/python-list
Trying to read in data for a file to a python application
Hi I have been trying to write a small application that is essentially user information application. https://raw.githubusercontent.com/zleap/AboutMe/master/Aboutme.py So far I have managed to write the data generated to a file, what I want to do now, is read this data back in when the user opens the program. Trying to use https://stackoverflow.com/questions/3277503/how-to-read-a-file-line-by-line-into-a-list with open(fname) as f: content = f.readlines() # you may also want to remove whitespace characters like `\n` at the end of each line content = [x.strip() for x in content] Trying to use this as a guide (hence my code is a little different). But am really stuck So far the GUI window appears but no widgets. So something is clearly getting stalled. To begin with If I can read the text in, and just display in the console this is a start, I can then see if I can figure out how to take that and insert the data in to the right places. Can anyone help please. Thanks Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: Trying to read in data for a file to a python application
On 26/02/2019 15:51, Paul Sutton wrote: > Hi > > I have been trying to write a small application that is essentially user > information application. > > https://raw.githubusercontent.com/zleap/AboutMe/master/Aboutme.py > > So far I have managed to write the data generated to a file, what I want > to do now, is read this data back in when the user opens the program. > > Trying to use > > https://stackoverflow.com/questions/3277503/how-to-read-a-file-line-by-line-into-a-list > > > with open(fname) as f: > content = f.readlines() > # you may also want to remove whitespace characters like `\n` at the end > of each line > content = [x.strip() for x in content] > > Trying to use this as a guide (hence my code is a little different). > But am really stuck > > So far the GUI window appears but no widgets. So something is clearly > getting stalled. > > To begin with If I can read the text in, and just display in the console > this is a start, I can then see if I can figure out how to take that and > insert the data in to the right places. > > Can anyone help please. > > Thanks > > Paul > Hi All Thank you for the comments and adding some 'sanity' to my problem solving. I will do as suggested and create a Python program to read / write then move on to integrating that in to the main program. Thanks again Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter
On 18/03/2019 16:00, Informatico de Neurodesarrollo wrote: > Hello friends: > > I am a beginner on programming in python. > > I want make a simple program that test continuously (every 5 seg) the > connection to internet and change the background color when are not > available. I try this , but not work properly: > > #!/usr/bin/env python3 > # -*- coding: utf-8 -*- > # > from tkinter import * > import socket, time > > def DetectarConexion(): > testConn = socket.socket(socket.AF_INET,socket.SOCK_STREAM) > try: > testConn.connect(('8.8.8.8', 80)) > testConn.close() > return True > except: > testConn.close() > return False > > root = Tk() > root.title("Conexión") > root.geometry("80x50") > > while True: > if DetectarConexion(): > # Background:Green > root.config(background="#38EB5C") > else: > # Background:Red > root.config(background="#F50743") > time.sleep(5) > > root.mainloop() > > > Any ideas, will be welcome. > > > T.I.A > > I asked about a tkinter app for a project I am working on a while back , what was suggested (which was a very useful suggestion) is get the routine and feedback working without the GUI first, so in this case a simply python program would ping something ever 5 mins and say if this was successful or not. Not sure if you would ping as such, but if you can get a normal python script to do what you want, then you can add a gui later. hope this helps Paul -- https://mail.python.org/mailman/listinfo/python-list