Skip to content

Commit ccd0465

Browse files
committed
fix processes modal, adjust border radius
1 parent 4092f10 commit ccd0465

File tree

3 files changed

+84
-89
lines changed

3 files changed

+84
-89
lines changed

donate_view.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import flet as ft
2+
3+
def on_donate_hover(e):
4+
e.control.bgcolor = "grey" if e.data == "true" else None
5+
e.control.content.controls[1].color = "black" if e.data == "true" else "white"
6+
e.control.border_radius = 10 if e.data =="true" else 0
7+
e.control.update()
8+
9+
def on_github_hover(e):
10+
e.control.bgcolor = "white" if e.data == "true" else None
11+
e.control.border_radius = 50 if e.data =="true" else 0
12+
e.control.update()
13+
14+
donate_view = ft.Column([
15+
ft.Row([
16+
ft.Column([
17+
ft.Text("Created by:", size=40),
18+
]),
19+
ft.Column([
20+
ft.Stack([
21+
ft.Image(
22+
src="https://avatars.githubusercontent.com/u/56776962?v=4",
23+
border_radius=60,
24+
width=210
25+
),
26+
ft.Container(
27+
content=ft.Image(src="images/Github.png", width=70),
28+
url="https://github.com/knightlygains/it-remote",
29+
offset=ft.transform.Offset(2, 2),
30+
on_hover=on_github_hover,
31+
tooltip="https://github.com/knightlygains"
32+
)
33+
]),
34+
ft.Text("Steven Whitney (KnightlyGains)", weight=ft.FontWeight.BOLD)
35+
]),
36+
], alignment=ft.MainAxisAlignment.CENTER, spacing=30),
37+
ft.Divider(),
38+
ft.Row([
39+
ft.Text("If you like this app and would like to support me, please consider donating:"),
40+
], spacing=15, alignment=ft.MainAxisAlignment.CENTER),
41+
ft.Row([
42+
ft.Container(
43+
content=ft.Column([
44+
ft.Image(src="images/ko-fi.png", width=70),
45+
ft.Text("Ko-Fi", weight=ft.FontWeight.BOLD)
46+
], horizontal_alignment=ft.CrossAxisAlignment.CENTER),
47+
margin=ft.margin.only(top=20),
48+
url="https://ko-fi.com/knightlygains",
49+
on_hover=on_donate_hover,
50+
padding=10
51+
),
52+
ft.Container(
53+
content=ft.Column([
54+
ft.Image(src="images/patreon.png", width=70),
55+
ft.Text("Patreon", weight=ft.FontWeight.BOLD)
56+
], horizontal_alignment=ft.CrossAxisAlignment.CENTER),
57+
margin=ft.margin.only(top=20),
58+
url="https://www.patreon.com/KnightlyGains",
59+
on_hover=on_donate_hover,
60+
padding=10
61+
)
62+
], alignment=ft.MainAxisAlignment.CENTER, spacing=30)
63+
], expand=1)

main.py

Lines changed: 21 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import flet as ft # Must be version 0.23.2 for now
1+
import flet as ft
22
import the_shell
33
import datetime, json, re, subprocess, ctypes, os, time, socket, pathlib, csv
44
from tutorial_btn import TutorialBtn
55
import text_values as text_values # Long text values stored in separate file
66
from dynamic_modal import DynamicModal
77
from are_you_sure import YouSure
8+
from donate_view import donate_view
89
from settings_values import *
910

1011
# Create settings.json if not exists and/or load saved values
@@ -17,8 +18,6 @@
1718
init_data = {"computers":[]}
1819
json.dump(init_data, file, indent=4)
1920

20-
computerlist_path = "assets/settings/lists/computers.txt"
21-
2221
#Cleanup old files
2322
printers_path = "assets/results/Printers"
2423
clearspace_path = "assets/results/ClearSpace"
@@ -359,7 +358,7 @@ def close_dialog(e = None):
359358
scroll=ft.ScrollMode.ADAPTIVE
360359
),
361360
bgcolor=settings_values['app_color'],
362-
border_radius=20
361+
border_radius=10
363362
)
364363

365364
def show_processes_modal(e):
@@ -402,10 +401,10 @@ def process_not_running(name, computer):
402401
return False
403402
return True
404403

405-
def add_new_process(process_object):
404+
def add_new_process(process_dict):
406405
nonlocal running_processes_count
407406
running_processes_count += 1
408-
list_of_processes.append(process_object)
407+
list_of_processes.append(process_dict)
409408
running_processes_count_text.value = f"{running_processes_count}"
410409
update_processes()
411410
page.update()
@@ -436,6 +435,9 @@ def update_processes():
436435
])
437436
)
438437
running_processes_controls.append(new_proc_card)
438+
439+
running_processes_container.content.controls = running_processes_controls
440+
439441
if len(list_of_processes) > 0:
440442
loading_ring.visible = True
441443
else:
@@ -468,7 +470,7 @@ def new_process(name, computers, date, id):
468470

469471
# -------------------- NAVIGATION --------------------
470472
def navigate_view(e):
471-
#If called by a control set equal to control value
473+
# If called by a control set equal to control value
472474
# Otherwise we are likely passing a specific index
473475
try:
474476
index = e.control.selected_index
@@ -738,7 +740,7 @@ def update_results(title_text = None, data = None, id = None, computer = None, *
738740
bgcolor=settings_values['app_color'],
739741
expand=True,
740742
alignment=ft.alignment.top_left,
741-
border_radius=20
743+
border_radius=10
742744
)
743745

744746
# Holds controls we removed from result_data
@@ -928,7 +930,7 @@ def select(e):
928930
], expand=1)
929931
]),
930932
bgcolor=settings_values['app_color'],
931-
border_radius=20,
933+
border_radius=10,
932934
border=ft.border.all(1, settings_values['app_color'])
933935
)
934936

@@ -1100,7 +1102,7 @@ def generate_result_card(leading, title, date, data, id, computer, action, **kwa
11001102
printer_wiz_list_container = ft.Container(
11011103
bgcolor=settings_values['app_color'],
11021104
content=printer_wiz_listview,
1103-
border_radius=20,
1105+
border_radius=10,
11041106
expand=True,
11051107
)
11061108

@@ -1594,7 +1596,7 @@ def open_tutorial_modal(e):
15941596
ft.Row([
15951597
ft.Text(f"{help_text}"),
15961598
], wrap=True, width=500),
1597-
border_radius=20,
1599+
border_radius=10,
15981600
border=ft.border.all(1, settings_values['app_color']),
15991601
padding=10,
16001602
)
@@ -2130,9 +2132,11 @@ def get_user_ids(e):
21302132
)
21312133

21322134
def open_pc_list(e):
2133-
2134-
powershell.open_pc_list()
2135-
2135+
if not os.path.exists(computerlist_path):
2136+
with open(computerlist_path, "w") as file:
2137+
print("Computer list file created.")
2138+
os.system(f'notepad.exe {computerlist_path}')
2139+
21362140
delete_users_checkbox = ft.Checkbox(label="Remove user profiles", value=False)
21372141
logout_users_checkbox = ft.Checkbox(label="Logout users before deletion", value=False)
21382142
use_list_checkbox = ft.Checkbox(label="Use list of PCs", value=False)
@@ -2427,7 +2431,7 @@ def sort_scripts_by_index(dict): # Use this to sort scripts by index before appe
24272431
)
24282432
])
24292433
]),
2430-
border_radius=20,
2434+
border_radius=10,
24312435
padding=10,
24322436
data=script_data
24332437
)
@@ -3244,7 +3248,7 @@ def check_for_changes(e):
32443248
),
32453249
bgcolor=settings_values['app_color'],
32463250
expand = 1,
3247-
border_radius=20
3251+
border_radius=10
32483252
)
32493253

32503254
actions_view = ft.Column([
@@ -3311,7 +3315,7 @@ def select_script(e: ft.FilePickerResultEvent):
33113315
content=scripts_list_view,
33123316
expand=True,
33133317
bgcolor=settings_values['app_color'],
3314-
border_radius=20,
3318+
border_radius=10,
33153319
padding=ft.padding.only(10,0,10,0)
33163320
)
33173321

@@ -3407,68 +3411,6 @@ def reset_script_search(e):
34073411

34083412
], expand=True)
34093413

3410-
def on_donate_hover(e):
3411-
e.control.bgcolor = "grey" if e.data == "true" else None
3412-
e.control.content.controls[1].color = "black" if e.data == "true" else "white"
3413-
e.control.border_radius = 20 if e.data =="true" else 0
3414-
e.control.update()
3415-
3416-
def on_github_hover(e):
3417-
e.control.bgcolor = "white" if e.data == "true" else None
3418-
e.control.border_radius = 50 if e.data =="true" else 0
3419-
e.control.update()
3420-
3421-
donate_view = ft.Column([
3422-
ft.Row([
3423-
ft.Column([
3424-
ft.Text("Created by:", size=40),
3425-
]),
3426-
ft.Column([
3427-
ft.Stack([
3428-
ft.Image(
3429-
src="https://avatars.githubusercontent.com/u/56776962?v=4",
3430-
border_radius=ft.border_radius.all(60),
3431-
width=210
3432-
),
3433-
ft.Container(
3434-
content=ft.Image(src="images/Github.png", width=70),
3435-
url="https://github.com/knightlygains/it-remote",
3436-
offset=ft.transform.Offset(2, 2),
3437-
on_hover=on_github_hover,
3438-
tooltip="https://github.com/knightlygains"
3439-
)
3440-
]),
3441-
ft.Text("Steven Whitney (KnightlyGains)", weight=ft.FontWeight.BOLD)
3442-
]),
3443-
], alignment=ft.MainAxisAlignment.CENTER, spacing=30),
3444-
ft.Divider(),
3445-
ft.Row([
3446-
ft.Text("If you like this app and would like to support me, please consider donating:"),
3447-
], spacing=15, alignment=ft.MainAxisAlignment.CENTER),
3448-
ft.Row([
3449-
ft.Container(
3450-
content=ft.Column([
3451-
ft.Image(src="images/ko-fi.png", width=70),
3452-
ft.Text("Ko-Fi", weight=ft.FontWeight.BOLD)
3453-
], horizontal_alignment=ft.CrossAxisAlignment.CENTER),
3454-
margin=ft.margin.only(top=20),
3455-
url="https://ko-fi.com/knightlygains",
3456-
on_hover=on_donate_hover,
3457-
padding=10
3458-
),
3459-
ft.Container(
3460-
content=ft.Column([
3461-
ft.Image(src="images/patreon.png", width=70),
3462-
ft.Text("Patreon", weight=ft.FontWeight.BOLD)
3463-
], horizontal_alignment=ft.CrossAxisAlignment.CENTER),
3464-
margin=ft.margin.only(top=20),
3465-
url="https://www.patreon.com/KnightlyGains",
3466-
on_hover=on_donate_hover,
3467-
padding=10
3468-
)
3469-
], alignment=ft.MainAxisAlignment.CENTER, spacing=30)
3470-
], expand=1)
3471-
34723414
# We assign different views to this in navigation
34733415
current_view = ft.Row([home], expand=True)
34743416
navigate_view(settings_values['home_tab']) #Set view to home tab saved in settings

the_shell.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import subprocess
2-
from os.path import exists
32
import json
43
import socket
54

@@ -16,15 +15,6 @@ def launch_script(self, script, ps_version):
1615
ps = "powershell.exe"
1716
p = subprocess.Popen([ps, script], creationflags=subprocess.CREATE_NEW_CONSOLE)
1817

19-
def open_pc_list(self):
20-
file_exists = exists(self.list_path)
21-
if file_exists:
22-
p = subprocess.run(["notepad.exe", self.list_path])
23-
else:
24-
with open(self.list_path, "w") as file:
25-
print("Computer list file created.")
26-
p = subprocess.run(["notepad.exe", self.list_path])
27-
2818
def enable_winrm(self, computer):
2919
p = subprocess.call([self.pspath, "-File", f"./assets/scripts/enable_winrm.ps1", f"{computer}"], creationflags=self.no_window)
3020
if p == 0:

0 commit comments

Comments
 (0)