I have created a script and it is meant to insert a variable into the insert field.
So far, I have been able to create the while
loop which prints the variable, so i know its working.
The frustrating part is that it doesn't bring up the window, it only prints the variable:
import time
import subprocess
from Tkinter import *
import urllib2
from ttk import *
import Tkinter as tk
root = Tk()
a= 0
while a<1:
print a
class Application(Frame):
"""GUI to display results of 'equity get'"""
def __init__(self, master):
"""initialise the Frame"""
Frame.__init__(self,master)
self.grid()
self.create_widgets()
def create_widgets(self):
"""Create button, text and entry Widget"""
"""what it is i.e. label"""
self.data = Label(self, text ="Data")
self.data1 = Entry(self, width = 10)
self.data.grid(column = 1, row = 1)
self.data1.grid(column = 2, row = 1)
self.data1.grid(column = 3, row = 1)
self.data1.insert(0,a)
app = Application(root)
root.title("reload test")
root.geometry("700x300")
root.mainloop()
The version below opens the window but the loop only iterates once, when in reality, i want it to continue all day.
import time
import subprocess
from Tkinter import *
import urllib2
from ttk import *
import Tkinter as tk
root = Tk()
a= 0
while a<1:
print a
class Application(Frame):
"""GUI to display results of 'equity get'"""
def __init__(self, master):
"""initialise the Frame"""
Frame.__init__(self,master)
self.grid()
self.create_widgets()
def create_widgets(self):
"""Create button, text and entry Widget"""
"""what it is i.e. label"""
self.data = Label(self, text ="Data")
self.data1 = Entry(self, width = 10)
self.data.grid(column = 1, row = 1)
self.data1.grid(column = 2, row = 1)
self.data1.grid(column = 3, row = 1)
self.data1.insert(0,a)
app = Application(root)
root.title("reload test")
root.geometry("700x200")
root.mainloop()
Thank you @guest for your refernce to using the after
function, however, I am a little unsure of where it needs to go.
@Wooble the variable a
will be a webscrape and I want it to insert the live information into my insert field Therefore, it will run a loop and insert what it finds!
Perhaps I am placing the after
function in the incorrect place!
import time
import subprocess
from Tkinter import *
import urllib2
from ttk import *
import Tkinter as tk
root = Tk()
a= 0
while a<1:
url = "https://uk.finance.yahoo.com/q?s=ngq14.nym&ql=1"
request= urllib2.Request(url)
handle = urllib2.urlopen(request)
content = handle.read()
splitted_page24 = content.split("<span id=\"yfs_l10_ngq14.nym\">", 1);
splitted_page24 = splitted_page24[1].split("</span>", 1)
print splitted_page24[0]
class Application(Frame):
"""GUI to display results of 'equity get'"""
def __init__(self, master):
"""initialise the Frame"""
Frame.__init__(self,master)
self.grid()
self.create_widgets()
def create_widgets(self):
"""Create button, text and entry Widget"""
"""what it is i.e. label"""
self.data = Label(self, text ="Data")
self.data1 = Entry(self, width = 10)
self.data.grid(column = 1, row = 1)
self.data1.grid(column = 2, row = 1)
self.data1.grid(column = 3, row = 1)
self.data1.insert(0,splitted_page24[0])
app = Application(root)
root.title("reload test")
root.geometry("700x300")
root.mainloop()
root.after(15)