Skip to content

Commit 8dc1b9b

Browse files
authored
Merge pull request #13 from Adam-Color/Develop
Merge for 1.4.0
2 parents 9b15eeb + f703016 commit 8dc1b9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+974
-415
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ venv/
138138
ENV/
139139
env.bak/
140140
venv.bak/
141+
.conda
141142

142143
# Spyder project settings
143144
.spyderproject

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![version](https://img.shields.io/badge/Version-1.3.0-white.svg)
1+
![version](https://img.shields.io/badge/Version-1.4.0-white.svg)
22
![license](https://img.shields.io/badge/License-GPL%20v3-blue.svg)
33
![python](https://img.shields.io/badge/Python-3.12-green.svg)
44

@@ -15,20 +15,25 @@ This program tracks the runtime of a specified application, logging the duration
1515

1616
## Installation
1717

18-
We now have proper installers for Mac OS and Windows!
19-
20-
Find them [here](https://github.com/Adam-Color/AppUsageGUI/releases)
18+
To install, follow the instructions for your platform found here:
2119

20+
[Windows](docs/install_windows.md) | [macOS](docs/install_macos.md)
2221

2322
## Contributing
2423

2524
### Contributions are welcome and needed! Here is a TODO list:
2625

27-
* add integrations with professional applications
26+
* Add integrations with professional applications
2827
* Optimize everything
2928
* Add support for tracking more than one executable per session
29+
* Impliment a better way to filter out non-gui apps on macOS
3030

3131
#### Version 2 ('v2-change-to-pyqt6' branch):
3232

33+
> [!WARNING]
34+
> In **macOS**, PyQt6 conflicts with py-objc, leading to a broken venv.
35+
> As a result, v2 is not currently being worked on until this issue is fixed.
36+
37+
* Merge and resolve changes from Develop into v2
3338
* Move to a single QT UI instead of multiple 'screens'
34-
* Add ways to analyze app usage data in the app
39+
* Add ways to analyze app usage data in the app

build.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
import shutil
44
import subprocess
5+
import platform
56
from src._version import __version__
67

78
# Project details
@@ -25,23 +26,32 @@ def build_executable():
2526

2627
icon_file = "src/core/resources/icon.ico" if os.name == 'nt' else "src/core/resources/icon.icns"
2728
print("Building the application...")
29+
if sys.platform == 'darwin':
30+
run_command('export PYTHONOPTIMIZE=1')
31+
windows_only_1 = ""
32+
else:
33+
run_command('set PYTHONOPTIMIZE=1')
34+
windows_only_1 = '--collect-all pywinauto'
2835
run_command(
29-
f'{python_executable} -m PyInstaller --onefile --clean --name {PROJECT_NAME} '
36+
f'{python_executable} -m PyInstaller -D --clean --name {PROJECT_NAME} '
37+
f'--noconfirm '
3038
f'--windowed --clean '
3139
f'--add-data "src/core:core" '
3240
f'--add-data "{icon_file}:." '
3341
f'--collect-submodules core '
3442
f'--collect-all psutil '
35-
f'--collect-all pynput '
3643
f'--collect-all tkinter '
44+
f'--collect-all pynput '
45+
f'--collect-all requests '
46+
f'--collect-all PIL '
47+
f'{windows_only_1} '
3748
f'--icon={icon_file} '
3849
f'--add-data "src/_version.py:." '
50+
f'--add-data "src/_path.py:." '
51+
f'--target-architecture {platform.machine()} '
3952
f'--debug=imports {ENTRY_POINT}'
4053
)
4154

42-
43-
44-
4555
def clean_up():
4656
"""Remove build artifacts."""
4757
print("Cleaning up...")
@@ -50,7 +60,7 @@ def clean_up():
5060
shutil.rmtree(folder)
5161

5262
def main():
53-
print(f"Starting build process for {PROJECT_NAME}...")
63+
print(f"Starting build process for {PROJECT_NAME} under {platform.machine()}...")
5464

5565
build_executable()
5666
clean_up()

docs/install_macos.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## macOS Installation Steps:
2+
* download the macOS setup .dmg [here](https://github.com/Adam-Color/AppUsageGUI/releases/latest) (under the "assets" section)
3+
* double-click the .dmg to open it
4+
* agree to the [license](../LICENSE.txt)
5+
* drag the "AppUsageGUI" folder to the "Applications" folder
6+
7+
## Running on macOS:
8+
>[!warning]
9+
>Due to Apple's restrictions when it comes to open source applications such as ours, workarounds are needed to get AppUsageGUI to run on macOS.
10+
11+
If you encounter the error message saying the app was not opened, click "done", then go into your security settings and allow AppUsageGUI to run on your device
12+
13+
Enter this in your terminal if AppUsageGUI still does not run:
14+
15+
```shell
16+
xattr -dr com.apple.quarantine /Applications/AppUsageGUI/AppUsageGUI.app
17+
```

docs/install_windows.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Windows Installation Steps:
2+
* download the windows setup .exe [here](https://github.com/Adam-Color/AppUsageGUI/releases/latest) (under the "assets" section)
3+
* double-click the setup .exe to open it
4+
* follow the instructions on screen
5+
* if the installer asks to replace a file that is already there, click "yes"

docs/release_template.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# AppUsageGUI v0.0.0
2+
3+
To install, follow the instructions for your platform found here:
4+
5+
[Windows](install_windows.md) | [macOS](install_macos.md)
6+
7+
## What's Changed
8+
9+
### Major Changes:
10+
*
11+
12+
### Minor Changes:
13+
*
14+
15+
### Patches:
16+
*

installers/macos_installer.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/bash
22
# This script is used to create the installer for the macOS version of the application
3+
app_version='1.4.0'
34

4-
create-dmg --volicon src/core/resources/icon.icns --volname AppUsageGUIsetup --window-pos 200 190 --window-size 800 400 --app-drop-link 600 185 --eula LICENSE.txt dist/AppUsageGUI_v1.3.0_macOS_arm64_setup.dmg dist/AppUsageGUI.app
5+
mv dist/AppUsageGUI.app dist/AppUsageGUI/
6+
7+
create-dmg --volicon src/core/resources/icon.icns --volname AppUsageGUIsetup --window-pos 200 190 --window-size 800 400 --app-drop-link 600 185 --eula LICENSE.txt dist/AppUsageGUI_v${app_version}_macOS_arm64_setup.dmg dist/

installers/windows_installer.iss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

44
#define MyAppName "AppUsageGUI"
5-
#define MyAppVersion "1.3.0"
5+
#define MyAppVersion "1.4.0"
66
#define MyAppPublisher "Adam Blair-Smith"
77
#define MyAppURL "https://github.com/Adam-Color/AppUsageGUI"
88
#define MyAppExeName "AppUsageGUI.exe"
9-
#define MyInstallerName "AppUsageGUI_v1.3.0_WINDOWS_setup"
9+
#define MyInstallerName "AppUsageGUI_v1.4.0_WINDOWS_setup"
1010

1111
[Setup]
1212
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
@@ -46,7 +46,8 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
4646
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
4747

4848
[Files]
49-
Source: "..\dist\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
49+
Source: "..\dist\{#MyAppName}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
50+
Source: "..\dist\{#MyAppName}\_internal\*"; DestDir: "{app}\_internal"; Flags: ignoreversion recursesubdirs createallsubdirs
5051
Source: "..\src\core\resources\icon.ico"; DestDir: "{app}/src/core/resources"; Flags: ignoreversion
5152
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
5253

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ PyScreeze==1.0.1
1212
pytweening==1.2.0
1313
rubicon-objc==0.5.0
1414
pyinstaller
15-
requests==2.32.3
15+
requests==2.32.3
16+
pillow==11.2.1

src/_path.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import sys
2+
import os
3+
4+
def resource_path(relative_path):
5+
""" Get absolute path to resource, works for dev and for PyInstaller """
6+
try:
7+
# PyInstaller creates a temp folder and stores path in _MEIPASS
8+
base_path = sys._MEIPASS
9+
except Exception:
10+
base_path = os.path.abspath(os.path.dirname(__file__))
11+
return os.path.join(base_path, relative_path)

src/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.3.0"
1+
__version__ = "1.4.0"

src/core/gui_root.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import tkinter as tk
2+
import traceback
3+
import time
24

35
from .logic_root import LogicRoot
46

@@ -17,7 +19,7 @@ def __init__(self, parent):
1719
self.parent = parent
1820

1921
# Initialize LogicRoot
20-
self.logic_controller = LogicRoot(self)
22+
self.logic = LogicRoot(self)
2123

2224
self.container = tk.Frame(self)
2325
self.container.pack(side="top", fill="both", expand=True)
@@ -35,7 +37,7 @@ def init_screens(self):
3537
# Pass the logic_controller when initializing screens
3638
for F in (MainWindow, SessionsWindow, SelectAppWindow, TrackerWindow, SaveWindow, CreateSessionWindow, SessionTotalWindow, TrackerSettingsWindow):
3739
page_name = F.__name__
38-
frame = F(parent=self.container, controller=self, logic_controller=self.logic_controller)
40+
frame = F(parent=self.container, controller=self, logic_controller=self.logic)
3941
self.frames[page_name] = frame
4042

4143
frame.grid(row=0, column=0, sticky="nsew")
@@ -49,19 +51,18 @@ def show_frame(self, page_name):
4951
def reset_frames(self):
5052
try:
5153
# Stop trackers
52-
if self.logic_controller.app_tracker:
53-
self.logic_controller.app_tracker.reset()
54+
if self.logic.app_tracker:
55+
self.logic.app_tracker.reset()
5456

55-
if self.logic_controller.time_tracker:
56-
self.logic_controller.time_tracker.reset()
57+
if self.logic.time_tracker:
58+
self.logic.time_tracker.reset()
5759

58-
if self.logic_controller.mouse_tracker:
59-
self.logic_controller.mouse_tracker.stop()
60+
if self.logic.mouse_tracker:
61+
self.logic.mouse_tracker.stop()
6062

6163
# Stop GUI threads
62-
for frame_name, frame in self.frames.items():
63-
if hasattr(frame, "stop_threads"):
64-
frame.stop_threads()
64+
self.frames["TrackerWindow"].stop_threads()
65+
self.frames["SessionTotalWindow"].stop_threads(wait=False)
6566

6667
# Destroy frames
6768
for frame_name, frame in self.frames.items():
@@ -73,21 +74,26 @@ def reset_frames(self):
7374
self.init_screens()
7475

7576
except Exception as e:
76-
print(f"Crash in reset_frames(): {e}")
77+
tk.messagebox.showerror("Error", f"Crash in reset_frames(): {str(traceback.format_exc())}")
7778

7879
def on_close(self):
7980
"""Handle cleanup and close the application."""
81+
82+
# Stop GUI threads
83+
self.frames["TrackerWindow"].stop_threads()
84+
self.frames["SessionTotalWindow"].stop_threads(wait=False)
85+
8086
# Stop the AppTracker thread
81-
if self.logic_controller.app_tracker:
82-
self.logic_controller.app_tracker.stop()
87+
if self.logic.app_tracker:
88+
self.logic.app_tracker.stop()
8389

8490
# stop the TimeTracker thread
85-
if self.logic_controller.time_tracker:
86-
self.logic_controller.time_tracker.stop()
91+
if self.logic.time_tracker:
92+
self.logic.time_tracker.stop()
8793

8894
# stop the MouseTracker thread
89-
if self.logic_controller.mouse_tracker:
90-
self.logic_controller.mouse_tracker.stop()
95+
if self.logic.mouse_tracker:
96+
self.logic.mouse_tracker.stop()
9197

9298
# Destroy the root window
9399
self.parent.destroy()

0 commit comments

Comments
 (0)