#!/usr/bin/env python3 import os import subprocess as sp import tkinter as tk import ttkbootstrap as ttk from tendo import singleton #setting up window pexs = ttk.Window(themename="darkly") window_height = 130 window_width = 400 pexs.title('Check CodeBerg Connection') pexs.tk.call('wm', 'iconphoto', pexs._w, tk.PhotoImage(file='/usr/share/pixmaps/peppermint-old.png')) #keep only instance at a time me = singleton.SingleInstance() def center_screen(): """ gets the coordinates of the center of the screen """ global screen_height, screen_width, x_cordinate, y_cordinate screen_width = pexs.winfo_screenwidth() screen_height = pexs.winfo_screenheight() # Coordinates of the upper left corner of the window to make the window appear in the center x_cordinate = int((screen_width/2) - (window_width/2)) y_cordinate = int((screen_height/2) - (window_height/2)) pexs.geometry("{}x{}+{}+{}".format(window_width, window_height, x_cordinate, y_cordinate)) def cb (): """Check if user can connect to codeberg""" cmd = os.system('wget -q --spider https://codeberg.org/Peppermint_OS/ ') if cmd == 0: #new placement for install btgo.place(x=220, y=70) #take the check button way out of view (hide) btck.place(x=-9000, y=0) #reset the label text lblexp.configure(text="Connection to CodeBerg successful!") #neplatment for label lblexp.place(x=40, y=30) else: os.system('python3 /opt/pypep/nointer.py') def ico (): """Run the bash""" sp.call(['xfce4-terminal', '-x','/opt/pypep/walls.sh']) def killme(): """Close the window""" pexs.destroy() os.popen ('python3 /opt/pypep/pge.py') #Message information lblexp = ttk.Label(pexs, text="Check Codeberg Connection...") lblexp.place(x=80, y=30) ###All the buttons and placements## btcan = ttk.Button(text='Cancel', bootstyle="danger-outline", width=8, command=killme ) btcan.place(x=100, y=70) btgo = ttk.Button(text='Install', bootstyle="danger-outline", width=8, command=ico) btck = ttk.Button(text='Check', bootstyle="danger-outline", width=8, command=cb) btck.place(x=220, y=70) #call Center screen center_screen() pexs.mainloop()