Run another python file that shows camera preview using Tkinter window

Axen_Rangs

I want run python file which opens camera preview by Tkinter button that placed on the main window.But it runs automatically camera window without opening the main window when executing the code.

from tkinter import *
import tkinter as tk
import os


window = tk.Tk()


window.title("Camera")
window.geometry("640x480")

lbl=Label(window,text="Start", font=("Arial Bold",10))
lbl.grid(column=0,row=0)
btn = Button(window, text="Start",command=os.system('capture.py'))
btn.grid(column=1, row=0)



window.mainloop()
Cool Cloud

It should be command=lambda: os.system('capture.py'):

btn = Button(window, text="Start",command=lambda: os.system('capture.py'))
btn.grid(column=1, row=0)

If you use () near a function name, it will call the function immediately. Which is not what you want, you want it to be called upon press, so just pass the function name(with lambda if it has arguments) and tkinter will handle the rest.

Collected from the Internet

Please contact debugcn@gmail.com to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Camera Using custom Camera Preview Renderer is not clear

From Dev

Camera Preview Using Surface Texture

From Dev

How to preview pdf file in browser using Python?

From Dev

Python- tkinter: Opening One Another image in another window?

From Dev

Custom camera shows dark picture preview when photo taken on Nexus

From Dev

Hide python shell while using tkinter window

From Dev

Hide python shell while using tkinter window

From Dev

Run another binary/exe file using Lua?

From Dev

Using the system function to run another .cpp file

From Dev

IOS8: Camera preview flickers when recording to a file and using AVCaptureSession/commitConfiguration

From Dev

Changing color of text in a tkinter window by using colorchooser in python 3 and tkinter

From Dev

Join another window in Qt Designer, using Python

From Dev

Tkinter window closes automatically after Python program has run in PyCharm

From Dev

Tkinter window closes automatically after Python program has run in PyCharm

From Dev

Logic within python and Tkinter: how to make a window run endlessly

From Dev

How to open and close another window with scrollbar in tkinter for python 3.5.?

From Dev

Run vim command when preview window is open

From Dev

Run vim command when preview window is open

From Dev

How do I run another file in python?

From Dev

How do I run another file in python?

From Dev

Using python to run command on a specific extension file from a folder and moves it to another folder after it's done

From Dev

Using XAML and ironpython in WPF, image shows in designer window but not when I run the program

From Dev

using java variable from another file method in run of other file

From Dev

using java variable from another file method in run of other file

From Dev

Unclosable window using tkinter

From Dev

Unclosable window using tkinter

From Dev

Simple Window using TkInter

From Dev

Tkinter Transfering Data to another Window

From Dev

list file names from a folder to a tkinter window, with python 3

Related Related

  1. 1

    Camera Using custom Camera Preview Renderer is not clear

  2. 2

    Camera Preview Using Surface Texture

  3. 3

    How to preview pdf file in browser using Python?

  4. 4

    Python- tkinter: Opening One Another image in another window?

  5. 5

    Custom camera shows dark picture preview when photo taken on Nexus

  6. 6

    Hide python shell while using tkinter window

  7. 7

    Hide python shell while using tkinter window

  8. 8

    Run another binary/exe file using Lua?

  9. 9

    Using the system function to run another .cpp file

  10. 10

    IOS8: Camera preview flickers when recording to a file and using AVCaptureSession/commitConfiguration

  11. 11

    Changing color of text in a tkinter window by using colorchooser in python 3 and tkinter

  12. 12

    Join another window in Qt Designer, using Python

  13. 13

    Tkinter window closes automatically after Python program has run in PyCharm

  14. 14

    Tkinter window closes automatically after Python program has run in PyCharm

  15. 15

    Logic within python and Tkinter: how to make a window run endlessly

  16. 16

    How to open and close another window with scrollbar in tkinter for python 3.5.?

  17. 17

    Run vim command when preview window is open

  18. 18

    Run vim command when preview window is open

  19. 19

    How do I run another file in python?

  20. 20

    How do I run another file in python?

  21. 21

    Using python to run command on a specific extension file from a folder and moves it to another folder after it's done

  22. 22

    Using XAML and ironpython in WPF, image shows in designer window but not when I run the program

  23. 23

    using java variable from another file method in run of other file

  24. 24

    using java variable from another file method in run of other file

  25. 25

    Unclosable window using tkinter

  26. 26

    Unclosable window using tkinter

  27. 27

    Simple Window using TkInter

  28. 28

    Tkinter Transfering Data to another Window

  29. 29

    list file names from a folder to a tkinter window, with python 3

HotTag

Archive