Skip to content

Commit 90103f6

Browse files
committed
Modifies most files to use absolute imports. Moves most of the widgets from BaseProcess into a new custom_widget.py Adds modern typing to binary.py
1 parent 298c543 commit 90103f6

File tree

18 files changed

+870
-691
lines changed

18 files changed

+870
-691
lines changed

flika/app/application.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1-
from ..logger import logger, handle_exception
2-
logger.debug("Started 'reading app/application.py'")
3-
4-
import sys, os, time
51
import ctypes
2+
import os
63
import platform
4+
import sys
5+
import time
76
import traceback
8-
logger.debug("Started 'reading app/application.py, importing qtpy'")
7+
98
from qtpy import QtCore, QtWidgets, QtGui
10-
logger.debug("Completed 'reading app/application.py, importing qtpy'")
9+
from qtpy.QtCore import QUrl
10+
from qtpy.QtGui import QDesktopServices
11+
12+
from flika import global_vars as g
13+
from flika.app.plugin_manager import PluginManager, load_local_plugins
14+
from flika.app.script_editor import ScriptEditor
15+
from flika.app.settings_editor import SettingsEditor, rectSettings, pointSettings, pencilSettings
16+
from flika.images import image_path
17+
from flika.logger import logger, handle_exception
18+
from flika.update_flika import checkUpdates
19+
from flika.utils.app import get_qapp
20+
from flika.utils.misc import nonpartial, send_user_stats, load_ui, send_error_report
21+
from flika.utils.thread_manager import run_in_thread, cleanup_threads
22+
from flika.version import __version__
1123

12-
from ..utils.misc import nonpartial, send_user_stats
13-
from ..utils.app import get_qapp
14-
from ..app.settings_editor import SettingsEditor, rectSettings, pointSettings, pencilSettings
15-
from .. import global_vars as g
16-
from .plugin_manager import PluginManager, load_local_plugins
17-
from .script_editor import ScriptEditor
18-
from ..utils.misc import load_ui, send_error_report
19-
from ..utils.thread_manager import run_in_thread, cleanup_threads
20-
from ..images import image_path
21-
from ..version import __version__
22-
from ..update_flika import checkUpdates
24+
logger.debug("Started 'reading app/application.py'")
2325

2426

2527
def status_pixmap(attention=False):
@@ -151,8 +153,8 @@ class FlikaApplication(QtWidgets.QMainWindow):
151153
"""
152154
def __init__(self):
153155
logger.debug("Started 'creating app.application.FlikaApplication'")
154-
from ..process.file_ import open_file, open_file_from_gui, open_image_sequence_from_gui, open_points, save_file, save_movie_gui, save_points, save_rois
155-
from ..process import setup_menus
156+
from flika.process.file_ import open_file, open_file_from_gui, open_image_sequence_from_gui, open_points, save_file, save_movie_gui, save_points, save_rois
157+
from flika.process import setup_menus
156158
logger.debug("Started 'creating app.application.FlikaApplication.app'")
157159
self.app = get_qapp(image_path('favicon.png'))
158160
logger.debug("Completed 'creating app.application.FlikaApplication.app'")
@@ -252,8 +254,8 @@ def setWindowSize(self):
252254

253255
def _make_menu(self):
254256
logger.debug("Started 'app.application.FlikaApplication._make_menu()'")
255-
from ..roi import open_rois
256-
from ..process.file_ import open_file, open_file_from_gui, open_image_sequence_from_gui, open_points, save_file, save_movie_gui, save_points, save_rois
257+
from flika.roi import open_rois
258+
from flika.process.file_ import open_file, open_file_from_gui, open_image_sequence_from_gui, open_points, save_file, save_movie_gui, save_points, save_rois
257259
fileMenu = self.menuBar().addMenu('File')
258260
openMenu = fileMenu.addMenu("Open")
259261
openMenu.addAction("Open Image/Movie", open_file_from_gui)
@@ -284,7 +286,7 @@ def _make_menu(self):
284286

285287
helpMenu = self.menuBar().addMenu("Help")
286288
url = 'http://flika-org.github.io'
287-
helpMenu.addAction("Documentation", lambda: QtGui.QDesktopServices.openUrl(QtCore.QUrl(url)))
289+
helpMenu.addAction("Documentation", lambda: QDesktopServices.openUrl(QUrl(url)))
288290
helpMenu.addAction("Check For Updates", checkUpdates)
289291
logger.debug("Completed 'app.application.FlikaApplication._make_menu()'")
290292

@@ -356,7 +358,7 @@ def dragEnterEvent(self, event):
356358
event.ignore()
357359

358360
def dropEvent(self, event):
359-
from ..process.file_ import open_file
361+
from flika.process.file_ import open_file
360362
if event.mimeData().hasUrls(): # if file or link is dropped
361363
for url in event.mimeData().urls():
362364
filename = url.toLocalFile()
@@ -397,7 +399,7 @@ def closeEvent(self, event):
397399

398400
def setup_button_icons(self):
399401
"""Ultra-simple button icon setup"""
400-
from ..images import image_path
402+
from flika.images import image_path
401403

402404
# One-liner for most buttons (assumes button name matches icon name)
403405
for btn in self.findChildren(QtWidgets.QPushButton):

flika/app/settings_editor.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
from ..logger import logger
2-
logger.debug("Started 'reading app/settings_editor.py'")
3-
41
import numpy as np
5-
from qtpy import QtWidgets, QtGui
62
from multiprocessing import cpu_count
7-
from ..utils.misc import setConsoleVisible
8-
from ..utils.BaseProcess import BaseDialog, BaseProcess, ColorSelector
9-
from .. import global_vars as g
3+
4+
from qtpy import QtWidgets, QtGui
5+
from pyqtgraph import ComboBox, mkBrush
6+
7+
from flika import global_vars as g
8+
from flika.logger import logger
9+
from flika.utils.BaseProcess import BaseProcess
10+
from flika.utils.custom_widgets import ColorSelector, BaseDialog
11+
from flika.utils.misc import setConsoleVisible
12+
13+
logger.debug("Started 'reading app/settings_editor.py'")
1014

1115

1216
__all__ = ['SettingsEditor', 'rectSettings', 'pointSettings', 'pencilSettings']
@@ -16,8 +20,6 @@
1620
class SettingsEditor(BaseDialog):
1721
gui = None
1822
def __init__(self):
19-
from pyqtgraph import ComboBox
20-
2123
old_dtype=g.settings['internal_data_type']
2224
dataDrop = ComboBox(items=data_types, default=old_dtype)
2325
showCheck = QtWidgets.QCheckBox()
@@ -133,7 +135,6 @@ def pointSettings(pointButton):
133135
items.append({'name': 'delete_all_points', 'string': 'Delete all points', 'object': delete_all_points})
134136

135137
def update():
136-
from pyqtgraph import mkBrush
137138
win = g.win
138139
g.settings['point_color'] = point_color.value()
139140
g.settings['point_size'] = point_size.value()

0 commit comments

Comments
 (0)