Skip to content

Commit

Permalink
Gui simplegui (#13)
Browse files Browse the repository at this point in the history
Added a PySimpleGUI-fueled interface that has feature parity with the command line.
  • Loading branch information
n2qzshce authored Mar 3, 2021
1 parent 890479c commit 04c4b61
Show file tree
Hide file tree
Showing 9 changed files with 344 additions and 8 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/pyinstaller-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name: Build executeable

env:
semver: 1.2.4.${{ github.run_number }}
semver: 1.3.0.${{ github.run_number }}
python-version: 3.8

on:
Expand Down Expand Up @@ -38,11 +38,16 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build executable
- name: Build CLI executable
run: |
pyinstaller -F radio_sync.py -n radio_sync-${{ matrix.short-name }}-${{ env.semver }}${{ matrix.exe-extension }}
${{ matrix.move-command }} dist/radio_sync-${{ matrix.short-name }}-${{ env.semver }}${{ matrix.exe-extension }} ./
7z a -tzip radio_sync-${{ matrix.short-name }}-${{ env.semver }}.zip radio_sync-${{ matrix.short-name }}-${{ env.semver }}${{ matrix.exe-extension }}
- name: Build GUI executable
run: |
pyinstaller -w -F radio_sync_gui.py -n radio_sync-${{ matrix.short-name }}_gui-${{ env.semver }}${{ matrix.exe-extension }}
${{ matrix.move-command }} dist/radio_sync-${{ matrix.short-name }}_gui-${{ env.semver }}${{ matrix.exe-extension }} ./
7z a -tzip radio_sync-${{ matrix.short-name }}-${{ env.semver }}.zip radio_sync-${{ matrix.short-name }}_gui-${{ env.semver }}${{ matrix.exe-extension }}
- name: Upload executable
id: upload_executable
uses: actions/upload-artifact@v2
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,25 @@ Currently supported radios:
* Baofeng uploads via CHiRP
* Yaesu FTM400 via RT systems application
* Anytone D8787 via D878UV software
* Connect Systems CS-800D via Connect Systems software

### How it works
This is a command line tool that will get you setting up your radios as quickly
as possible. Open a command window with `cmd` and navigate to the directory that
has the executable in it. Running the executable without parameters will display a
prompt along with explanations of the commands.

Basic command format: `radio_sync.exe --help`
Basic command format: `radio-sync.exe --help`

There is now also a GUI version of the tool that has all the same features of the
command line version! This version will be the `radio-sync_gui.exe` file in the
release package.

##### Windows defender will warn you about opening the GUI version. Click on the `more info` dialogue to run.

### General requirements
* You will need some knowledge of how to run a command line application.
* The executeable should be placed in a directory by itself. This will allow for
* You may want some knowledge of how to run a command line application.
* The executable should be placed in a directory by itself. This will allow for
the `wizard` to create the necessary `in` and `out` folders.

##### **This program will create folders around it!**
Expand Down
4 changes: 3 additions & 1 deletion ham/radio_generator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import csv
import os

from ham.util import file_util, radio_types
from ham.dmr.dmr_contact import DmrContact
Expand All @@ -19,6 +20,7 @@ def __init__(self, radio_list):
self._validator = Validator()

def generate_all_declared(self):
self._validator.flush_names()
file_errors = self._validate_files_exist()
if len(file_errors) > 0:
logging.error("--- FILE MISSING ERRORS, CANNOT CONTINUE ---")
Expand Down Expand Up @@ -103,7 +105,7 @@ def generate_all_declared(self):
radio_files[radio].close()
additional_data.output(radio)

logging.info("Radio generator complete")
logging.info(f"Radio generator complete. Your output files are in `{os.path.abspath('out')}`")
return

def _validate_files_exist(self):
Expand Down
12 changes: 12 additions & 0 deletions ham/util/radio_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,15 @@ def supports_dmr(radio_type):
}

return switch[radio_type]


def pretty_name(radio_type):
switch = {
DEFAULT: 'Default',
BAOFENG: 'Baofeng Radios',
FTM400: 'Yaesu FTM-400',
D878: 'Anytone D878',
CS800: 'Connect Systems CS800',
}

return switch[radio_type]
7 changes: 6 additions & 1 deletion ham/util/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ def __init__(self):
self._zone_template = RadioZone.create_empty()
self._dmr_user_template = DmrUser.create_empty()

self._short_names = None
self._medium_names = None
self._long_names = None
return

def flush_names(self):
self._short_names = dict()
self._medium_names = dict()
self._long_names = dict()
return

def validate_dmr_user(self, cols, line_num, file_name):
needed_cols_dict_gen = dict(self._dmr_user_template.__dict__)
Expand Down
2 changes: 2 additions & 0 deletions pip.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[kivy]
index-url = https://kivy.org/downloads/simple/
37 changes: 37 additions & 0 deletions radio_sync_gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import asyncio
import logging
import os
import sys

from ui.app_window import AppWindow


def setup_logger():
os.environ["KIVY_NO_CONSOLELOG"] = "1"
os.environ["KIVY_NO_FILELOG"] = "1"
logger = logging.getLogger('radio_sync')
formatter = logging.Formatter(
fmt='%(asctime)s.%(msecs)03d %(levelname)7s %(filename).6s:%(lineno)3s: %(message)s',
datefmt="%Y-%m-%d %H:%M:%S"
)

handler = logging.StreamHandler(stream=sys.stdout)
handler.setFormatter(formatter)

logger.setLevel(logging.DEBUG)
logger.addHandler(handler)
logging.root = logger


async def main():
setup_logger()
# kivy does some janky logging, so any logs that get put before this point are likely to get gobbled up.
app_window = AppWindow()
await app_window.async_run()

return


if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
openpyxl == 3.0.6
pyinstaller == 4.2
pyinstaller == 4.2
pysimplegui == 4.34.0
Loading

0 comments on commit 04c4b61

Please sign in to comment.