V
V
vadimeasy2021-10-30 11:58:18
Python
vadimeasy, 2021-10-30 11:58:18

How to set IF in Checkbutton Tkinker?

Hello, I am making a program for clients so that they themselves install the software that they need to work. There is a certain module (I can’t disclose it) for which you need to install the module itself, OpenVPN, and make settings. I wrote the settings script on the computer through PyAutoGUI, I install the VPN through ZipFile in the directory I need. Now I'm making an interface through Tkinter, I need to set in the interface what the client will download for himself.
617d088ae23dd147862812.png
It turns out to do only so that when you click on the Checkbutton, the function immediately starts, and I need to make sure that the user checks the boxes where necessary and clicks to install, then the functions of the selected values ​​\u200b\u200bare started to run. Please advise how this can be implemented. Here is the code:

import os
import time
import pyautogui as pag 
import time
import os 
import shutil
from os import path
from shutil import copyfile
import glob
import zipfile

def setup():
    os.startfile('Start.py', 'runas')
    
    
    

def set_set():
    port = str(input("Введите ваш порт: "))
    command = str("New-NetFirewallRule -DisplayName 'UTM_transport'".format())
    command1 = str(" -Profile @('Domain', 'Private', 'Public' ) ".format())
    command2 = str("-Direction Inbound -Action Allow -Protocol TCP -LocalPort @('8228')".format())

    VPN = str('Set-Service OpenVPNService -startuptype automatic -passthru'.format())
    UTM = str('Set-Service Transport -startuptype automatic -passthru'.format())

    restartVPN = str('Restart-Service -Name OpenVPNService'.format())
    restartUTM = str('Restart-Service -Name Transport'.format())

    # Запуск скрипта и отработка
    os.startfile('powershell', 'runas')
    time.sleep(3)
    if command == ("New-NetFirewallRule -DisplayName 'UTM_transport'"):
        pag.typewrite(command, 0.01)
        pag.typewrite(command1, 0.01)
        pag.typewrite(command2, 0.01)
        pag.press('enter') 


        time.sleep(1)
        pag.typewrite(VPN, 0.01)
        time.sleep(1)
        pag.press('enter')
        time.sleep(1)
        pag.typewrite(UTM, 0.01)
        pag.press('enter')

        time.sleep(1)
        pag.typewrite(restartUTM, 0.01)
        pag.press('enter')
        time.sleep(1)
        pag.typewrite(restartVPN, 0.01)
        pag.press('enter')
        pag.typewrite('exit')
        pag.press('enter')    


# def set_vpn():

    	
    # directory_file = (r"C:/Users/kolom/Desktop/Main programm/Auto_EGAIS/OpenVPN.zip")
    # # directory_file_unpuck = str(input('Куда распаковать:'))

    # fantasy_zip = zipfile.ZipFile(directory_file)
    # fantasy_zip.extractall(r'C:/Program Files')


    # print('Successfully')

    # fantasy_zip.close()


import tkinter as tk 
from tkinter import * 
win = tk.Tk()
frame = Frame()
photo = tk.PhotoImage(file='ico.ico')
win.iconphoto(False, photo)
win.config(bg='#CCC')
win.title('UTM Настройка')
win.geometry("500x300+590+240")


label_1 = tk.Label(win, text='Выбери, что будем устанавливать.', bg='#CCC', font=('Arial',14))
label_1.pack()

var = tk.StringVar()
var.set("OFF")
settings_utm = tk.Checkbutton(text="Настроить связь с сервером",bg='#CCC',onvalue=1, font=('Arial',12))

settings_utm.pack(anchor=W, padx=20)

setup_utm = tk.Checkbutton(text="Установить УТМ",bg='#CCC',onvalue=1, font=('Arial',12))
setup_utm.pack(anchor=W, padx=20)

setup_vpn = tk.Checkbutton(text="Установить Open VPN",bg='#CCC',onvalue=1, font=('Arial',12))
setup_vpn.pack(anchor=W, padx=20)

btn = tk.Button(win, text='Установить', command=setup)
btn.pack()

win.resizable(False, False)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question