Skip to content

Commit

Permalink
add icon, update .desktop file
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-dvorak committed Apr 16, 2024
1 parent 75243a9 commit 5b81245
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
9 changes: 9 additions & 0 deletions dosview.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=DosView
Exec=dosview %f
Icon=/usr/local/share/icons/icon_ust.png
MimeType=text/plain;text/dos
Terminal=false
Categories=Utility;TextEditor;
33 changes: 29 additions & 4 deletions dosview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@
from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from PyQt5.QtWidgets import QFileDialog
import random
import csv
from matplotlib.figure import Figure
from threading import Thread

import matplotlib.pyplot as plt
import pandas as pd
from PyQt5.QtGui import QIcon

def parse_file(file_path):

metadata = {}
df_log = pd.read_csv(file_path, sep = ',', header = None, names=range(505))
max_size = 0

with open(file_path, 'r') as file:
for line in file:
parts_size = len(line.split(","))
if parts_size > max_size: max_size = parts_size

df_log = pd.read_csv(file_path, sep = ',', header = None, names=range(max_size), low_memory=False)
data_types = df_log[0].unique().tolist()

df_spectrum = df_log [df_log[0] == '$HIST']
Expand Down Expand Up @@ -75,7 +84,10 @@ def plot(self):

self.axes2 = self.figure.add_subplot(212) # Add second subplot
self.axes2.clear() # Clear previous plot
self.axes2.plot(self.data[2], 'b.', alpha=0.3)
self.axes2.plot(self.data[2], 'b.-', alpha=0.3)

self.axes2.set_yscale('log')
self.axes2.set_xscale('log')

self.axes2.set_xlabel('Channel')
self.axes2.set_ylabel('Count')
Expand All @@ -100,11 +112,14 @@ def __init__(self, file_path):
self.height = 400
self.file_path = file_path
self.initUI()

def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)

# Set the window icon
self.setWindowIcon(QIcon('media/icon_ust.png'))

m = PlotCanvas(self, width=5, height=4, file_path=self.file_path)
self.setCentralWidget(m)
m.move(0,0)
Expand All @@ -117,9 +132,19 @@ def initUI(self):

def main():
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('file_path', type=str, help='Path to the input file')
parser.add_argument('file_path', type=str, help='Path to the input file', default=None)
args = parser.parse_args()

if not args.file_path:
print("Please provide a file path")
file_dialog = QFileDialog()
file_path, _ = file_dialog.getOpenFileName()
if not file_path:
print("No file selected")
sys.exit()
else:
args.file_path = file_path

app = QApplication(sys.argv)
ex = App(args.file_path)
sys.exit(app.exec_())
Expand Down
Binary file added media/icon_ust.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
'dosview = dosview:main',
],
},
data_files=[
('/usr/local/share/applications', ['dosview.desktop']),
('/usr/local/share/icons', ['media/icon_ust.png'])
],
install_requires=required,
classifiers=[
'Development Status :: 3 - Alpha',
Expand Down

0 comments on commit 5b81245

Please sign in to comment.