Python Forum
tkinter GUI, problem running seperate files
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter GUI, problem running seperate files
#1
Hello. I'm fairly new to Python.

If I run the program from my editor it works fine, every .py file opens when buttons is pressed and does what it's supposed to. Once I try to double click the main program or run it with a hotkey, and click the button that opens the .py file, nothing happens. In this case the button labeled "test" inside class StartPage.

What I want to happen: The program has to open seperate .py files when a button is clicked, when the program is started with a hotkey.

I have tried:
-subprocess.Popen
-subprocess.call
-os
-change to .pyw
-pythonpath
-specified pathing to .py file

I run python 3.7
Windows 10 MSC v.1915 64 bit (AMD64)

The code is 400 lines, so I made it a bit shorter:

import tkinter as tk
from tkinter import ttk
import subprocess
import time




class MainClass(tk.Tk):

    def __init__(self, *args, **kwargs):
        
        tk.Tk.__init__(self, *args, **kwargs)
        container = tk.Frame(self)
        self.geometry("1000x700+300+60")
        container.pack(side="top", fill="both", expand = True)

        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}

        for F in (StartPage, PageOne, PageTwo, PageThree, PageFour, PageFourSubOne, PageFive, PageSix):

            frame = F(container, self)

            self.frames[F] = frame

            frame.grid(row=0, column=0, sticky="nsew")

        self.show_frame(StartPage)

    def show_frame(self, cont):

        frame = self.frames[cont]
        frame.tkraise()

        
class StartPage(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self,parent)
        
        label = tk.Label(self, text="Hovedmeny", font=("arial", 20), fg="Blue")
        label.pack(pady=10,padx=10)
        

        def test():
            subprocess.call("autoguitest2.py", shell=True)
            controller.show_frame(StartPage)

#input('1: press enter to continue') (Coudn't get this working)

        testbase = ttk.Button(self, text="Test", command=test)
        testbase.pack()

class PageOne(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="CO2", font=LARGE_FONT)
        label.pack(pady=10,padx=10)
        
        style = ttk.Style()
        style.configure("tilbake.TButton", width=20, height=2, font=('arial', 12, "bold"), bg="Blue")
        
        hovedmeny = ttk.Button(self, text="Tilbake til hovedmenyen", style="tilbake.TButton",
                            command=lambda: controller.show_frame(StartPage))
        
        hovedmeny.pack()
        
        label = tk.Label(self, text="Label", font=('arial', 15, "bold"), fg="Red")
        label.pack(pady=10,padx=10)

        def trekilo_ordre():
            subprocess.call("CO2.py", shell=True)
            controller.show_frame(StartPage)
            
            
        style.configure("3kg.TButton", width=40, height=2, font=("arial", 12, "bold"))

        trekilo = ttk.Button(self, text="CO2 3kg", style="3kg.TButton", command=trekilo_ordre)


app = MainClass()
app.mainloop()
Reply
#2
Quote:Once I try to double click the main program or run it with a hotkey, and click the button that opens the .py file, nothing happens
Python is an interpreter and needs to be run from python.
so the method to run a python script from from command line is:
python scriptname.py
double clicking on the .py won't run it.
Reply
#3
(Sep-24-2019, 04:22 PM)Larz60+ Wrote:
Quote:Once I try to double click the main program or run it with a hotkey, and click the button that opens the .py file, nothing happens
Python is an interpreter and needs to be run from python.
so the method to run a python script from from command line is:
python scriptname.py
double clicking on the .py won't run it.

It does work for me to just double click it., as .py files are associated with the interpreter. That said, running the program from cmd doesn't solve it. I also tried the subprocess.Popen("python autoguitest.py") Doesn't make any difference sadly.

Thanks for trying though.
Reply
#4
post entire code so it can be run
Reply
#5
Are you attempting to double-click the *.py file or are you making an *.exe out of it that you are then trying to launch?

From my understanding (which might not be spot on) if you are doing the former just associating the file extension with the interpreter does not mean it is going to launch it as you feel it should -- for that is not how the interpreter works. You actually need to associate double-click with "running" a python script from within an interpreter which is different than what the describe methodology is actually doing.

Some where along they way you have to launch something that the connects with the interpreter in a way that will allow you then launch a program from within the interpreter's umbrella
Reply
#6
(Sep-24-2019, 04:22 PM)Larz60+ Wrote: double clicking on the .py won't run it.
Try deleting the __pycache__ directory and any .pyc files and rerun with the python version you want
Recommended Tutorials:
Reply
#7
(Sep-24-2019, 05:22 PM)Larz60+ Wrote: post entire code so it can be run

Here's the entire code:

import tkinter as tk
from tkinter import ttk
import subprocess
import time



LARGE_FONT= ("Verdana", 12)
BOLD_FONT= ("arial", 10, "bold")


class MainClass(tk.Tk):

    def __init__(self, *args, **kwargs):
        
        tk.Tk.__init__(self, *args, **kwargs)
        container = tk.Frame(self)
        self.geometry("1000x700+300+60")
        container.pack(side="top", fill="both", expand = True)

        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}

        for F in (StartPage, PageOne, PageTwo, PageThree, PageFour, PageFourSubOne, PageFive, PageSix):

            frame = F(container, self)

            self.frames[F] = frame

            frame.grid(row=0, column=0, sticky="nsew")

        self.show_frame(StartPage)

    def show_frame(self, cont):

        frame = self.frames[cont]
        frame.tkraise()

        
class StartPage(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self,parent)
        
        label = tk.Label(self, text="Hovedmeny", font=("arial", 20), fg="Blue")
        label.pack(pady=10,padx=10)
        

        def test():
            subprocess.call("autoguitest2.py", shell=True)
            #input('1: press enter to continue')

        def kopiere_kontaktperson():
            subprocess.call("contact_astea_to_so.py", shell=True)
            controller.show_frame(StartPage)
        
        style = ttk.Style()
        style.configure("co2_knapp.TButton", font=("arial", 14), width=60, height=2, background="lightgrey")
        
        co2_knapp = ttk.Button(self, text="Bytte av CO2", style="co2_knapp.TButton",
                            command=lambda: controller.show_frame(PageOne))
        
        co2_knapp.pack(anchor="n")
        
        
        style.configure("tom_knapp.TButton", font=("arial", 14), width=60, height=2, 
                        background="lightgrey")
        
        tom_knapp = ttk.Button(self, text="Tom for vann", style="tom_knapp.TButton", 
                            command=lambda: controller.show_frame(PageFour))
        
        tom_knapp.pack(anchor="n")
       
        style.configure("varenummer.TButton", font=("arial", 14), width=60, height=2, 
                        background="lightgrey")

        
        style.configure("pyautogui.TButton", font=("arial", 14), width=60, height=2, 
                        background="lightgrey")
        

        style.configure("button2.TButton", font=("arial", 16), width=20, height=2, 
                        background="lightgrey")
        
        filterbytte = ttk.Button(self, text="Filterbytte", style="tom_knapp.TButton",
                                 command=lambda: controller.show_frame(PageThree))
        filterbytte.pack()
        
        uvfeil = ttk.Button(self, text="UV-Feil", style ="tom_knapp.TButton",
                            command=lambda: controller.show_frame(PageFive))
        uvfeil.pack()
        
        lekkasje = ttk.Button(self, text="Lekkasje", style="tom_knapp.TButton",
                              command=lambda: controller.show_frame(PageSix))
        lekkasje.pack()
        
        button2 = ttk.Button(self, text="Ferdige tekster", style="button2.TButton",
                            command=lambda: controller.show_frame(PageTwo))
        button2.pack(pady=20)

        kopiere_kp = ttk.Button(self, text="KP fra Astea til SO - Ha Astea oppe i bakgrunnen og SO på andre skjermen", style="tom_knapp.TButton", command=kopiere_kontaktperson)
        kopiere_kp.pack(pady=20)

        testbase = ttk.Button(self, text="Test", command=test)
        testbase.pack()       
        
class PageOne(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="CO2", font=LARGE_FONT)
        label.pack(pady=10,padx=10)
        
        style = ttk.Style()
        style.configure("tilbake.TButton", width=20, height=2, font=('arial', 12, "bold"), bg="Blue")
        
        hovedmeny = ttk.Button(self, text="Tilbake til hovedmenyen", style="tilbake.TButton",
                            command=lambda: controller.show_frame(StartPage))
        
        hovedmeny.pack()
        
        label = tk.Label(self, text="OBS! Husk å ha ordren oppe i Astea før du trykker på 'Opprett ordre'", font=('arial', 15, "bold"), fg="Red")
        label.pack(pady=10,padx=10)

        def trekilo_ordre():
            subprocess.call("CO2.py", shell=True)
            controller.show_frame(StartPage)
            
            
        style.configure("3kg.TButton", width=40, height=2, font=("arial", 12, "bold"))

        trekilo = ttk.Button(self, text="Opprett ordre på CO2 3kg", style="3kg.TButton", command=trekilo_ordre)
        #tikilo = ttk.Button(self, text="10kg", style="3kg.TButton", command=trekilo_ordre)
        #sekshundre = ttk.Button(self, text="600g", style="3kg.TButton", command=trekilo_ordre)
        
        trekilo.pack()
        #tikilo.pack()
        #sekshundre.pack()
        #button2 = ttk.Button(self, text="Page Two",
                            #command=lambda: controller.show_frame(PageTwo))
        #button2.pack()


class PageTwo(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="Ferdig tekster", font=LARGE_FONT)
        label.pack(pady=10,padx=10)
        
        style = ttk.Style()
        style.configure("tilbake.TButton", width=20, height=2, font=('arial', 12, "bold"))
        
        hovedmeny = ttk.Button(self, text="Tilbake til hovedmeny", style="tilbake.TButton",
                            command=lambda: controller.show_frame(StartPage))
        
        hovedmeny.pack(pady=5)
        
        from pynput.keyboard import Controller as KeyboardController
        keyboard = KeyboardController()
     

        def open_tekst_en():
            time.sleep(2)
            for char in "Jeg trenger serienummer på maskinen det gjelder. Dette finner du bak på maskinen under en strekkode. Ta gjerne et bilde om du er usikker.":
                keyboard.press(char)
                keyboard.release(char)
            app.destroy()

        def open_tekst_to():
            time.sleep(2)
            for char in "Jeg trenger serienummer på maskinen det gjelder. Dette finner du inni maskinen på en sølvgrå lapp. Ta gjerne et bilde om du er usikker. ":
                keyboard.press(char)
                keyboard.release(char)
            app.destroy()

        def open_tekst_tre():
            time.sleep(2)
            for char in "Flytting til ny lokasjon koster 3300,- + kjøring. Må vi legge rør ut over 5m kommer jobben og rørdeler i tillegg. Skal dere ha Aquasafe har vi en pakkepris på 5100,- + kjøring.\n\n\nVennligst bekreft prisen, så legger jeg inn en flytteordre og sender deg en ordrebekreftelse.":
                keyboard.press(char)
                keyboard.release(char)
            app.destroy()       
                
        def open_tekst_fire():
            time.sleep(2)
            for char in "Denne maskinen har ingen serviceavtale, så service koster derfor 1990,- + kjøring + evt. deler som benyttes. Filter og UV er inkludert i prisen. \n \n \nVennligst bekreft prisen, så legger jeg inn en service med en gang.":
                keyboard.press(char)
                keyboard.release(char)
            app.destroy()
        
        
        tekst_en = ttk.Button(self, text="Vannmaskin - Spørre om serienummer", style="pyautoguibuttons.TButton", command=open_tekst_en)
        tekst_en.pack(pady=2)
        
        tekst_to = ttk.Button(self, text="Kaffemaskin - Spørre om serienummer", style="pyautoguibuttons.TButton", command=open_tekst_to)
        tekst_to.pack(pady=2)        
        
        tekst_tre = ttk.Button(self, text="Flytting - Nytt bygg", style="pyautoguibuttons.TButton", command=open_tekst_tre)
        tekst_tre.pack(pady=2)        
        
        tekst_fire = ttk.Button(self, text="Vannmaskin - Service til kr: 1990,- + kjøring", style="pyautoguibuttons.TButton", command=open_tekst_fire)
        tekst_fire.pack(pady=2)

        label = tk.Label(self, text="OBS! Trykk i vinduet teksten skal i etter du trykker på knappen, skrives etter 2 sek", font=('arial', 15, "bold"), fg="Red")
        label.pack(pady=10,padx=10)
        
        
class PageThree(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="Filterbytte", font=LARGE_FONT)
        label.pack(pady=10,padx=10)
        style = ttk.Style()

        style = ttk.Style()
        style.configure("tilbake.TButton", width=20, height=2, font=('arial', 12, "bold"))
        
        hovedmeny = ttk.Button(self, text="Tilbake til hovedmenyen", style="tilbake.TButton",
                            command=lambda: controller.show_frame(StartPage))
        
        hovedmeny.pack()

        def filterbytte_ordre():
            subprocess.call("filterbytte.py", shell=True)
            controller.show_frame(StartPage)
            
        filterbytte = ttk.Button(self, text="Opprette ordre i Astea for filterbytte", style="tom_knapp.TButton", command=filterbytte_ordre)
        filterbytte.pack(pady=10)

        advarsel = tk.Label(self, text="OBS! Husk å ha ordren oppe i Astea før du trykker på 'Opprett ordre'", font=('arial', 15, "bold"), fg="Red")
        advarsel.pack(pady=10,padx=10)        


class PageFour(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="Hovedmeny for PyautoGUI", font=LARGE_FONT)
        label.pack(pady=10,padx=10)
        style = ttk.Style()

        style = ttk.Style()
        style.configure("tilbake.TButton", width=30, height=2, font=('arial', 12, "bold"))
        
        hovedmeny = ttk.Button(self, text="Tilbake til hovedmenyen", style="tilbake.TButton",
                            command=lambda: controller.show_frame(StartPage))
        hovedmeny.pack(pady=10)

        def tom_uten():
            subprocess.call("TOM.py", shell=True)
            controller.show_frame(StartPage)

        style.configure("pyautoguibuttons.TButton", width=60, height=2, font=('arial', 12, "bold"))
        tom1 = ttk.Button(self, text="TOM UTEN ANTALL", style="pyautoguibuttons.TButton", command=tom_uten)
        tom1.pack(pady=3)        
        tom2 = ttk.Button(self, text="TOM MED ANTALL", style="pyautoguibuttons.TButton", command=lambda: controller.show_frame(PageFourSubOne))
        tom2.pack(pady=3)
        



class PageFourSubOne(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="Definert antall TOM", font=LARGE_FONT)
        label.pack(pady=10,padx=10)
        style = ttk.Style()

        style = ttk.Style()
        style.configure("tilbake.TButton", width=30, height=2, font=('arial', 12, "bold"))
        
        hovedmeny = ttk.Button(self, text="Tilbake til hovedmenyen", style="tilbake.TButton",
                            command=lambda: controller.show_frame(StartPage))
        
        hovedmeny.pack(pady=10)
        import subprocess
        def tom():
            file = open("tom definert.txt", 'w')
            file.write(str(tom_antall.get()))
            file.close()
            subprocess.call("autogui_tom.py", shell=True)
            controller.show_frame(StartPage)


        
        

        style.configure("pyautoguibuttons2.Tbutton", width=80, height=3, font=('arial', 15, "bold"))




        tom_antall = tk.StringVar()

        
        lable = tk.Label(self, text="Skriv inn antallet kunden ønsker under: ", font=LARGE_FONT)
        lable.pack(pady=10,padx=10)
        
        entry_box = tk.Entry(self, textvariable=tom_antall)
        entry_box.pack()
        
        
        tomdef = ttk.Button(self, text="OPPRETT ORDRE", style="pyautoguibuttons2.TButton", command=tom)
        tomdef.pack(pady=10,padx=10)        
        
        label = tk.Label(self, text="OBS! Husk å ha ordren oppe i Astea før du trykker på Opprett ordre", font=('arial', 15, "bold"), fg="Red")
        label.pack(pady=10,padx=10)
        label2 = tk.Label(self, text="Programmet bytter selv til Astea, trykk på knappen og vent.", font=('arial', 15, "bold"), fg="Blue")
        label2.pack(pady=10,padx=10)



class PageFive(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="UV-Feil", font=LARGE_FONT)
        label.pack(pady=10,padx=10)
        style = ttk.Style()
        style.configure("tilbake.TButton", width=30, height=2, font=('arial', 12, "bold"))
        
        hovedmeny = ttk.Button(self, text="Tilbake til hovedmenyen", style="tilbake.TButton",
                            command=lambda: controller.show_frame(StartPage))
        hovedmeny.pack(pady=10)

        def uv_ordre_wl3():
            subprocess.call("UV_Feil_WL3.py", shell=True)
            controller.show_frame(StartPage)

        def uv_ordre_wl4():
            subprocess.call("UV_Feil_WL4.py", shell=True)
            controller.show_frame(StartPage)
            
        def uv_ordre_generell():
            subprocess.call("UV_Feil.py", shell=True)
            controller.show_frame(StartPage)


        style.configure("pyautoguibuttons.TButton", width=60, height=2, font=('arial', 12, "bold"))
        uv_wl3 = ttk.Button(self, text="Opprett ordre: Purification lyser ikke", style="pyautoguibuttons.TButton", command=uv_ordre_wl3)
        uv_wl3.pack(pady=2)        
        uv_wl4 = ttk.Button(self, text="Opprett ordre: UV-Feil i display WL4", style="pyautoguibuttons.TButton", command=uv_ordre_wl4)
        uv_wl4.pack(pady=2)
        uv_generell = ttk.Button(self, text="Opprett ordre: Generell UV-Feil", style="pyautoguibuttons.TButton", command=uv_ordre_generell)
        uv_generell.pack(pady=2) 

        label = tk.Label(self, text="OBS! Husk å ha ordren oppe i Astea før du trykker på Opprett ordre", font=('arial', 15, "bold"), fg="Red")
        label.pack(pady=10,padx=10)

class PageSix(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="Lekkasje", font=LARGE_FONT)
        label.pack(pady=10,padx=10)
        style = ttk.Style()
        style.configure("tilbake.TButton", width=30, height=2, font=('arial', 12, "bold"))
        
        hovedmeny = ttk.Button(self, text="Tilbake til hovedmenyen", style="tilbake.TButton",
                            command=lambda: controller.show_frame(StartPage))
        hovedmeny.pack(pady=10)

        def lekkasje1():
            subprocess.call("lekkasje.py", shell=True)
            controller.show_frame(StartPage)
        def lekkasje2():
            subprocess.call("lekkasje2.py", shell=True)
            controller.show_frame(StartPage)



        style.configure("pyautoguibuttons.TButton", width=60, height=2, font=('arial', 12, "bold"))
        lekkasje_plain = ttk.Button(self, text="Opprett ordre: Lekkasje", style="pyautoguibuttons.TButton", command=lekkasje1)
        lekkasje_plain.pack(pady=2)        
        lekkasje_inni = ttk.Button(self, text="Opprett ordre: Lekkasje inni/under", style="pyautoguibuttons.TButton", command=lekkasje2)
        lekkasje_inni.pack(pady=2)

        label = tk.Label(self, text="OBS! Husk å ha ordren oppe i Astea før du trykker på Opprett ordre", font=('arial', 15, "bold"), fg="Red")
        label.pack(pady=10,padx=10)


app = MainClass()
app.mainloop()
Reply
#8
Still unable to run because of dependencies,

add this module (temporarilly):
CreateDict.py
import os


class CreateDict:
    def __init__(self):
        os.chdir(os.path.abspath(os.path.dirname(__file__)))

    def new_dict(self, dictname):
        setattr(self, dictname, {})

    def add_node(self, parent, nodename):
        node = parent[nodename] = {}
        return node

    def add_cell(self, nodename, cellname, value):
        cell =  nodename[cellname] = value
        return cell

    def display_dict(self, dictname, level=0):
        indent = " " * (4 * level)
        for key, value in dictname.items():
            if isinstance(value, dict):
                print(f'\n{indent}{key}')
                level += 1
                self.display_dict(value, level)
            else:
                print(f'{indent}{key}: {value}')
            if level > 0:
                level -= 1


def testit():
    # instantiate class
    cd = CreateDict()

    # create new dictionary named CityList
    cd.new_dict('CityList')

    # add node Boston
    boston = cd.add_node(cd.CityList, 'Boston')
    # add sub node Resturants
    bos_resturants = cd.add_node(boston, 'Resturants')

    # Add subnode 'Spoke Wine Bar' to parent bos_resturants
    spoke = cd.add_node(bos_resturants, 'Spoke Wine Bar')
    cd.add_cell(spoke, 'Addr1', '89 Holland St')
    cd.add_cell(spoke, 'City', 'Sommerville')
    cd.add_cell(spoke, 'Addr1', '02144')
    cd.add_cell(spoke, 'Phone', '617-718-9463')

    # Add subnode 'Highland Kitchen' to parent bos_resturants
    highland = cd.add_node(bos_resturants, 'Highland Kitchen')
    cd.add_cell(highland, 'Addr1', '150 Highland Ave')
    cd.add_cell(highland, 'City', 'Sommerville')
    cd.add_cell(highland, 'ZipCode', '02144')
    cd.add_cell(highland, 'Phone', '617-625-1131')

    # display dictionary
    print(f'\nCityList Dictionary')
    cd.display_dict(cd.CityList)
    print(f'\nraw data: {cd.CityList}')

if __name__ == '__main__':
    testit()
then add the following 5 lines after line 32 (your script)
        import CreateDict
        import sys
        cd = CreateDict.CreateDict()
        cd.display_dict(self.frames)
        sys.exit(0)
run and post results
Reply
#9
(Sep-25-2019, 10:34 AM)Larz60+ Wrote: run and post results

runfile('C:/Users/myuser/.spyder-py3/allinone_test_2.py', wdir='C:/Users/myuser/.spyder-py3')
<class '__main__.StartPage'>: .!frame.!startpage
<class '__main__.PageOne'>: .!frame.!pageone
<class '__main__.PageTwo'>: .!frame.!pagetwo
<class '__main__.PageThree'>: .!frame.!pagethree
<class '__main__.PageFour'>: .!frame.!pagefour
<class '__main__.PageFourSubOne'>: .!frame.!pagefoursubone
<class '__main__.PageFive'>: .!frame.!pagefive
<class '__main__.PageSix'>: .!frame.!pagesix
An exception has occurred, use %tb to see the full traceback.

SystemExit: 0

C:\Users\myuser\AppData\Local\Continuum\miniconda3\Lib\site-packages\IPython\core\interactiveshell.py:3334: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)


###
What I find to be strange is that my program runs error free as long as I run it through my editor Spyder.(Works through PyCharm as well) I had a simpler version using Tkinter but not ttk some time ago that worked just fine, so my (unprofessional) theory is that it's something wrong with Tkinter/my code and not my computer.
I then, and now, add a shortcut to the program.py in "C:\ProgramData\Microsoft\Windows\Start Menu\Programs" and bind that shortcut to F8. I checked permissions in Windows and all checks out.
I have several other shortcuts to .py/.pyw files in there that runs from a macro on my mouse, and works perfectly.

One example is "umpriority.pyw - Snarvei"

from pynput.keyboard import Key, Controller as KeyboardController
from pynput.mouse import Button, Controller as MouseController
import time

keyboard = KeyboardController()
mouse = MouseController()

mouse.position = (1135, 628)
mouse.click(Button.left, 1)
time.sleep(0.1)
mouse.position = (1231, 627)
mouse.click(Button.left, 1)
time.sleep(0.6)

keyboard.press(Key.tab)
keyboard.release(Key.tab)
time.sleep(0.5)
for char in "Nødservice POU/COF":
    keyboard.press(char)
    keyboard.release(char)
    time.sleep(0.01)

time.sleep(0.5)

for char in range(9):
    keyboard.press(Key.tab)
    keyboard.release(Key.tab)
    time.sleep(0.05)

for char in "11":
    keyboard.press(char)
    keyboard.release(char)
    time.sleep(0.05)
time.sleep(0.1)

mouse.position = (234, 634)
mouse.click(Button.left, 1)
Reply
#10
(Sep-24-2019, 05:34 PM)Denni Wrote: Are you attempting to double-click the *.py file or are you making an *.exe out of it that you are then trying to launch?

From my understanding (which might not be spot on) if you are doing the former just associating the file extension with the interpreter does not mean it is going to launch it as you feel it should -- for that is not how the interpreter works. You actually need to associate double-click with "running" a python script from within an interpreter which is different than what the describe methodology is actually doing.

Some where along they way you have to launch something that the connects with the interpreter in a way that will allow you then launch a program from within the interpreter's umbrella


program = allinone.py

I'm using a hotkey in Windows on the shortcut I put in the startup folder so that it works after reboot. I bind the shortcut to F8 and the program runs when I press it. I can move around inside the program, all subwindows work but once I try to use a function that opens another .py / .pyw file, nothing happens. If i run the program through my editor, everything works.
If I double click "allinone.py" the program starts and the GUI i created shows up.

I don't fully understand your explaination. I don't know how the interpreter works behind the scenes in Windows, but it seems to start every .py file I double click and run the code inside.

I can upload a short video of it if my explaination is bad.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Help running a loop inside a tkinter frame Konstantin23 3 1,449 Aug-10-2023, 11:41 AM
Last Post: Konstantin23
  Why is the program not running? Is there a logical or syntax problem? behi00 10 1,999 Apr-01-2023, 12:50 AM
Last Post: woooee
  [Tkinter] Have tkinter button toggle on and off a continuously running function AnotherSam 5 4,918 Oct-01-2021, 05:00 PM
Last Post: Yoriz
  Python3 tkinter radiobutton problem Nick_tkinter 14 5,830 Feb-15-2021, 11:01 PM
Last Post: Nick_tkinter
  tkinter python button position problem Nick_tkinter 3 3,483 Jan-31-2021, 05:15 AM
Last Post: deanhystad
  [Tkinter] ClockIn/Out tkinter problem Maryan 2 2,163 Oct-12-2020, 03:42 AM
Last Post: joe_momma
  tkinter| listbox.insert problem Maryan 3 3,438 Sep-29-2020, 05:34 PM
Last Post: Yoriz
  Tkinter problem DPaul 6 4,047 May-28-2020, 03:40 PM
Last Post: DPaul
  [Tkinter] Tkinter - I have problem after import varaible or function from aGUI to script johnjh 2 2,521 Apr-17-2020, 08:12 PM
Last Post: johnjh
  [Tkinter] Problem with tkinter when creating .exe file Jan_97 2 4,537 Feb-27-2020, 05:17 PM
Last Post: Jan_97

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020