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 [email protected] 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

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

From Dev

How to preview pdf file in browser using Python?

From Dev

How to run python script from another .py file and show in current window

From Dev

Hide python shell while using tkinter window

From Dev

Hide python shell while using tkinter window

From Dev

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

From Dev

Custom camera shows dark picture preview when photo taken on Nexus

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 run a file from another python file

From Dev

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

From Dev

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

From Dev

Run vim command when preview window is open

From Dev

Run vim command when preview window is open

From Dev

Run another binary/exe file using Lua?

From Dev

Using the system function to run another .cpp file

From Dev

Join another window in Qt Designer, using Python

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

How do I run another file in python?

From Dev

How do I run another file in python?

From Dev

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

From Dev

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

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

Related Related

  1. 1

    Camera Using custom Camera Preview Renderer is not clear

  2. 2

    Camera Preview Using Surface Texture

  3. 3

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

  4. 4

    How to preview pdf file in browser using Python?

  5. 5

    How to run python script from another .py file and show in current window

  6. 6

    Hide python shell while using tkinter window

  7. 7

    Hide python shell while using tkinter window

  8. 8

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

  9. 9

    Custom camera shows dark picture preview when photo taken on Nexus

  10. 10

    Tkinter window closes automatically after Python program has run in PyCharm

  11. 11

    Tkinter window closes automatically after Python program has run in PyCharm

  12. 12

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

  13. 13

    how to run a file from another python file

  14. 14

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

  15. 15

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

  16. 16

    Run vim command when preview window is open

  17. 17

    Run vim command when preview window is open

  18. 18

    Run another binary/exe file using Lua?

  19. 19

    Using the system function to run another .cpp file

  20. 20

    Join another window in Qt Designer, using Python

  21. 21

    Unclosable window using tkinter

  22. 22

    Unclosable window using tkinter

  23. 23

    Simple Window using TkInter

  24. 24

    Tkinter Transfering Data to another Window

  25. 25

    How do I run another file in python?

  26. 26

    How do I run another file in python?

  27. 27

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

  28. 28

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

  29. 29

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

HotTag

Archive