Created
November 21, 2016 17:24
-
-
Save Nsk1107/a74fe868fb0dd8e50908f4cc8692d3de to your computer and use it in GitHub Desktop.
Label updating using after()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import cv2 | |
| from PIL import Image, ImageTk | |
| from Tkinter import Tk, Label | |
| import Support | |
| def vp_start_gui(): | |
| '''Starting point when module is the main routine.''' | |
| global val, w, root | |
| root = Tk() | |
| top = New_Toplevel_1 (root) | |
| top.updateImage() | |
| root.mainloop() | |
| w = None | |
| def create_New_Toplevel_1(root, *args, **kwargs): | |
| '''Starting point when module is imported by another program.''' | |
| global w, w_win, rt | |
| rt = root | |
| w = Toplevel (root) | |
| top = New_Toplevel_1 (w) | |
| return (w, top) | |
| def destroy_New_Toplevel_1(): | |
| global w | |
| w.destroy() | |
| w = None | |
| class New_Toplevel_1: | |
| def __init__(self, top=None): | |
| '''This class configures and populates the toplevel window. | |
| top is the toplevel containing window.''' | |
| self._bgcolor = '#d9d9d9' # X11 color: 'gray85' | |
| self._fgcolor = '#000000' # X11 color: 'black' | |
| self._compcolor = '#d9d9d9' # X11 color: 'gray85' | |
| self._ana1color = '#d9d9d9' # X11 color: 'gray85' | |
| self._ana2color = '#d9d9d9' # X11 color: 'gray85' | |
| top.geometry("600x449+650+151") | |
| top.title("New Toplevel 1") | |
| top.configure(background="#d9d9d9") | |
| top.configure(highlightbackground="#d9d9d9") | |
| top.configure(highlightcolor="black") | |
| self.lblFrame = Label(top) | |
| self.lblFrame.place(relx=0.03, rely=0.04, height=411, width=544) | |
| self.lblFrame.configure(activebackground="#f9f9f9") | |
| self.lblFrame.configure(activeforeground="black") | |
| self.lblFrame.configure(background="#d9d9d9") | |
| self.lblFrame.configure(disabledforeground="#a3a3a3") | |
| self.lblFrame.configure(foreground="#000000") | |
| self.lblFrame.configure(highlightbackground="#d9d9d9") | |
| self.lblFrame.configure(highlightcolor="black") | |
| self.lblFrame.configure(text='''Label''') | |
| def updateImage(self): | |
| cv2image = cv2.cvtColor(Support.frame, cv2.COLOR_BGR2RGBA) | |
| img = Image.fromarray(cv2image) | |
| imgtk = ImageTk.PhotoImage(image=img) | |
| self.lblFrame.imgtk = imgtk | |
| self.lblFrame.configure(image=imgtk) | |
| self.lblFrame.after(10, self.updateImage) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment