예제 #1
0
    def test_cmb_filter_type(self):
        """Test setting <Filter Type> ComboBox and the effect on the table shape"""
        self.init()
        self.set_cmb_box(self.ui.cmbFilterType, 'IIR')
        self.assertEqual(qget_cmb_box(self.ui.cmbFilterType, data=False),
                         "IIR")
        self.ui.cmbFilterType.currentIndexChanged.emit(1)
        QTest.mouseClick(self.ui.cmbFilterType, Qt.LeftButton)
        QTest.keyClick(QApplication.instance().focusWidget(), Qt.Key_PageDown)
        QTest.qWait(1000)
        QTest.keyClick(QApplication.instance().focusWidget(), Qt.Key_Return)
        QTest.qWait(1000)
        self.assertEqual(qget_cmb_box(self.ui.cmbFilterType, data=False),
                         "IIR")
        # https://vicrucann.github.io/tutorials/qttest-signals-qtreewidget/
        self.assertEqual(self.form.tblCoeff.rowCount(), 3)
        self.assertEqual(self.form.tblCoeff.columnCount(), 2)
        item_10 = self.form.tblCoeff.item(0, 1)  # row, col
        self.assertEqual(float(item_10.text()), 1)

        self.set_cmb_box(self.ui.cmbFilterType, 'FIR')

        self.assertEqual(self.form.tblCoeff.rowCount(), 3)
        self.assertEqual(self.form.tblCoeff.columnCount(), 1)
        self.log.warning("test_cmb_filter_type finished")
예제 #2
0
파일: firwin.py 프로젝트: tspiteri/pyfda
def main():
    import sys
    from pyfda.libs.compat import QApplication, QFrame

    app = QApplication(sys.argv)

    # instantiate filter widget
    filt = Firwin()
    filt.construct_UI()
    wdg_firwin = getattr(filt, 'wdg_fil')

    layVDynWdg = QVBoxLayout()
    layVDynWdg.addWidget(wdg_firwin, stretch=1)

    filt.LPman(fb.fil[0])  # design a low-pass with parameters from global dict
    print(fb.fil[0][filt.FRMT])  # return results in default format

    frmMain = QFrame()
    frmMain.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
    frmMain.setLayout(layVDynWdg)

    mainw = frmMain
    mainw.show()

    app.exec_()
예제 #3
0
def main():
    import sys
    from pyfda.libs.compat import QApplication
    app = QApplication(sys.argv)
    mainw = Plot_tau_g(None)
    app.setActiveWindow(mainw)
    mainw.show()
    sys.exit(app.exec_())
예제 #4
0
    def test_write_table(self):
        """
        Test writing to table in various formats
            https://www.francescmm.com/testing-qtablewidget-with-qtest/
            https://vicrucann.github.io/tutorials/qttest-signals-qtreewidget/
        """
        self.init()
        self.initialize_form()
        self.initialize_fixpoint_format()
        self.assertEqual(self.form.tblCoeff.isVisible(), True)
        self.assertEqual(self.form.tblCoeff.isEnabled(), True)
        x = self.form.tblCoeff.columnViewportPosition(0)
        y = self.form.tblCoeff.rowViewportPosition(1)
        QTest.mouseClick(self.form.tblCoeff.viewport(), Qt.LeftButton,
                         Qt.NoModifier, QPoint(x, y))
        QTest.keyClicks(QApplication.instance().focusWidget(), "13", delay=100)
        # QTest.keyClick(QApplication.instance().focusWidget(), Qt.Key_Return, delay=1000)
        QTest.mouseClick(self.ui.butSave, Qt.LeftButton)
        QTest.qWait(1000)
        # self.set_table_value(1, 0, 25)  # row, col, value
        self.assertEqual(self.form.tblCoeff.item(0, 0).text(), "1.0")
        self.assertEqual(self.form.tblCoeff.item(1, 0).text(), "0.0078125")
        # self.assertEqual(self.get_table_value(1, 0), "1")

        # self.assertEqual(self.get_table_value(1, 1), "15")

        # self.assertEqual(self.form.tblCoeff.rowCount(), 2)
        self.log.warning("test_write_table finished")
예제 #5
0
def main():
    import sys
    from pyfda.libs.compat import QApplication

    app = QApplication(sys.argv)

    mainw = Plot_Tran_Stim_UI(None)
    layVMain = QVBoxLayout()
    layVMain.addWidget(mainw.wdg_stim)
    layVMain.setContentsMargins(
        *params['wdg_margins'])  # (left, top, right, bottom)

    mainw.setLayout(layVMain)

    app.setActiveWindow(mainw)
    mainw.show()
    sys.exit(app.exec_())
예제 #6
0
파일: pyfdax.py 프로젝트: chipmuenk/pyfda
    def __init__(self, parent=None):
        super(QMainWindow, self).__init__()
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        # create clipboard instance that can be accessed from other modules
        fb.clipboard = QApplication.clipboard()

        # initialize the FilterTreeBuilder class:
        # read config file and construct filter tree from it
        _ = Tree_Builder()  # TODO_ couldn't this be a function?
        self._construct_UI()
예제 #7
0
def main():
    from pyfda import pyfda_rc as rc
    from pyfda.libs.compat import QApplication
    app = QApplication(sys.argv)
    app.setStyleSheet(rc.qss_rc)

    mainw = InputTabWidgets(None)
    app.setActiveWindow(mainw)
    mainw.show()
    sys.exit(app.exec_())
예제 #8
0
        self.ax.set_ylim(
            [max(np.nanmin(tau_g) - 0.5, 0),
             np.nanmax(tau_g) + 0.5])
        self.ax.set_xlim(fb.fil[0]['freqSpecsRange'])

        self.redraw()

# ------------------------------------------------------------------------------

    def redraw(self):
        """
        Redraw the canvas when e.g. the canvas size has changed
        """
        self.mplwidget.redraw()


# ------------------------------------------------------------------------------

if __name__ == "__main__":
    """ Run widget standalone with `python -m pyfda.plot_widgets.plot_tau_g` """
    import sys
    from pyfda.libs.compat import QApplication
    from pyfda import pyfda_rc as rc

    app = QApplication(sys.argv)
    app.setStyleSheet(rc.qss_rc)
    mainw = Plot_tau_g()
    app.setActiveWindow(mainw)
    mainw.show()
    sys.exit(app.exec_())
예제 #9
0
    def ui2dict(self):
        """
        Update the quantization dict and the attributes `self.ovfl` and
        `self.quant` from the UI
        """
        self.ovfl = self.cmbOvfl.currentText()
        self.quant = self.cmbQuant.currentText()

        self.q_dict.update({'ovfl': self.ovfl, 'quant': self.quant})

        if self.sender():
            obj_name = self.sender().objectName()
            dict_sig = {'wdg_name': self.wdg_name, 'ui': obj_name}
            self.emit(dict_sig)

    # --------------------------------------------------------------------------
    def dict2ui(self, q_dict):
        """ Update UI from passed dictionary """
        pass


# ==============================================================================
if __name__ == '__main__':

    from pyfda.libs.compat import QApplication
    app = QApplication(sys.argv)
    mainw = UI_W(None)
    mainw.show()

    app.exec_()
예제 #10
0
파일: pyfdax.py 프로젝트: chipmuenk/pyfda
def main():
    """
    entry point for the pyfda application
    see http://pyqt.sourceforge.net/Docs/PyQt4/qapplication.html :

    "For any GUI application using Qt, there is precisely *one* QApplication object,
    no matter whether the application has 0, 1, 2 or more windows at any given time.
    ...
    Since the QApplication object does so much initialization, it must be created
    *before* any other objects related to the user interface are created."
    """
    # instantiate QApplication object, passing command line arguments
    if len(rc.qss_rc) > 20:
        app = QApplication(sys.argv)
        app.setStyleSheet(rc.qss_rc)  # this is a proper style sheet
        style = "Using 'pyfda' style sheet."
    else:
        qstyle = QApplication.setStyle(
            rc.qss_rc)  # no, this is just a name for a system stylesheet
        app = QApplication(sys.argv)
        if qstyle:
            style = 'Using system style "{0}".'.format(rc.qss_rc)
        else:
            style = 'Style "{0}" not found, falling back to default style.'.format(
                rc.qss_rc)

    mainw = pyFDA()
    logger.info("Logging to {0}".format(dirs.LOG_DIR_FILE))
    logger.info(style)

    if dirs.OS.lower() == "windows":
        # Windows taskbar is not for "Application Windows" but for "Application
        # User Models", grouping several instances of an application under one
        # common taskbar icon. Python apps are sometimes grouped under the icon
        # for Pythonw.exe, sometimes the icon is just blank. The following
        # instructions tell Windows that pythonw is merely hosting other applications.
        import ctypes
        myappid = u'chipmuenk.pyfda.v0.4'
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

    # set taskbar icon
    app.setWindowIcon(QIcon(':/pyfda_icon.svg'))

    # Sets the active window to the active widget in response to a system event
    app.setActiveWindow(mainw)
    # Set default icon for window
    mainw.setWindowIcon(QIcon(':/pyfda_icon.svg'))

    screen_resolution = app.desktop().screenGeometry()
    screen_h, screen_w = screen_resolution.height(), screen_resolution.width()
    logger.info("Starting pyfda with screen resolution: %d x %d", screen_w,
                screen_h)

    if screen_h < 800:
        delta = 50
    else:
        delta = 100
    # set position + size of main window on desktop
    mainw.setGeometry(20, 20, screen_w - delta,
                      screen_h - delta)  # top L / top R, dx, dy
    # Give the keyboard input focus to this widget if this widget
    # or one of its parents is the active window:
    #    mainw.setFocus()
    mainw.show()

    #start the application's exec loop, return the exit code to the OS
    app.exec_()  # sys.exit(app.exec_()) and app.exec_() have same behaviour
예제 #11
0
from pyfda.libs.pyfda_lib import unique_roots

from pyfda.plot_widgets.mpl_widget import MplWidget


class Myplot(QWidget):
    # incoming, connected in sender widget (locally connected to self.process_sig_rx() )
    sig_rx = pyqtSignal(object)

    def __init__(self, parent):
        super(Myplot, self).__init__(parent)
        self.needs_calc = True  # flag whether plot needs to be recalculated
        self.needs_redraw = True  # flag whether plot needs to be redrawn
        self.tool_tip = "My first pyfda plot widget"
        self.tab_label = "xxx"


#------------------------------------------------------------------------------

if __name__ == '__main__':

    from pyfda.libs.compat import QApplication
    import sys
    app = QApplication(sys.argv)
    mainw = Myplot(None)

    app.setActiveWindow(mainw)
    mainw.show()

    sys.exit(app.exec_())
예제 #12
0
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 14 11:57:19 2017

@author: Christian Muenker
"""
import sys
import unittest
import logging

from pyfda.libs.pyfda_qt_lib import qget_cmb_box, qset_cmb_box
from pyfda.libs.compat import (Qt, QTest, QSignalSpy, QPoint, QApplication,
                               QTableWidgetItem)
from pyfda.input_widgets.input_coeffs import Input_Coeffs

app = QApplication(sys.argv)


class FilterCoeffsTest(unittest.TestCase):
    '''Test the FilterCoeffs GUI'''
    def init(self):
        '''Create the GUI'''
        self.form = Input_Coeffs()
        self.form.show()
        self.ui = self.form.ui
        self.log = logging.getLogger("LOG")

    def get_cmb_box(self, cmb_wdg):
        """
        get current text entry of combobox `cmb_wdg` (lower cased)
        """
예제 #13
0
def main():
    """ 
    entry point for the pyfda application 
    see http://pyqt.sourceforge.net/Docs/PyQt4/qapplication.html :
    
    "For any GUI application using Qt, there is precisely *one* QApplication object,
    no matter whether the application has 0, 1, 2 or more windows at any given time.
    ...
    Since the QApplication object does so much initialization, it must be created 
    *before* any other objects related to the user interface are created."     
    """
    # instantiate QApplication object, passing command line arguments
    if len(rc.qss_rc) > 20:
        app = QApplication(sys.argv)
        app.setStyleSheet(rc.qss_rc)  # this is a proper style sheet
        style = "Using 'pyfda' style sheet."
    else:
        qstyle = QApplication.setStyle(
            rc.qss_rc)  # no, this is just a name for a system stylesheet
        app = QApplication(sys.argv)
        if qstyle:
            style = 'Using system style "{0}".'.format(rc.qss_rc)
        else:
            style = 'Style "{0}" not found, falling back to default style.'.format(
                rc.qss_rc)

    app.setWindowIcon(QIcon(':/pyfda_icon.svg'))

    mainw = pyFDA()
    logger.info("Logging to {0}".format(dirs.LOG_DIR_FILE))
    logger.info(style)

    # Sets the active window to the active widget in response to a system event.
    app.setActiveWindow(mainw)
    mainw.setWindowIcon(QIcon(':/pyfda_icon.svg'))

    screen_resolution = app.desktop().screenGeometry()
    screen_h, screen_w = screen_resolution.height(), screen_resolution.width()
    logger.info("Starting pyfda with screen resolution: %d x %d", screen_w,
                screen_h)

    if screen_h < 800:
        delta = 50
    else:
        delta = 100
    # set position + size of main window on desktop
    mainw.setGeometry(20, 20, screen_w - delta,
                      screen_h - delta)  # top L / top R, dx, dy
    # Give the keyboard input focus to this widget if this widget
    # or one of its parents is the active window:
    #    mainw.setFocus()
    mainw.show()

    #start the application's exec loop, return the exit code to the OS
    app.exec_()  # sys.exit(app.exec_()) and app.exec_() have same behaviour
예제 #14
0
    def redraw(self):
        """
        Redraw the canvas when e.g. the canvas size has changed
        """
        self.mplwidget.redraw()


# ==============================================================================
if __name__ == '__main__':
    """ Run widget standalone with `python -m pyfda.plot_widgets.plot_fft_win` """
    import sys
    from pyfda.libs.compat import QApplication
    from pyfda.libs.pyfda_fft_windows_lib import get_windows_dict
    from pyfda import pyfda_rc as rc

    app = QApplication(sys.argv)
    app.setStyleSheet(rc.qss_rc)
    fb.clipboard = QApplication.clipboard()  # create clipboard instance
    win_names_list = [
        "Boxcar", "Rectangular", "Barthann", "Bartlett", "Blackman",
        "Blackmanharris", "Bohman", "Cosine", "Dolph-Chebyshev", "Flattop",
        "General Gaussian", "Gauss", "Hamming", "Hann", "Kaiser", "Nuttall",
        "Parzen", "Slepian", "Triangular", "Tukey"
    ]

    # initialize windows dict with the list above and an initial window
    win_dict = get_windows_dict(win_names_list=win_names_list,
                                cur_win_name="Hann")

    mainw = Plot_FFT_win(None, win_dict, ignore_close_event=False)
예제 #15
0
        logger.debug("Sending fixpoint results")
        dict_sig = {
            'sender': __name__,
            'fx_sim': 'set_results',
            'fx_results': self.fx_results
        }
        self.sig_tx.emit(dict_sig)
        qstyle_widget(self.butSimHDL, "normal")
        return


###############################################################################

if __name__ == '__main__':
    from pyfda.libs.tree_builder import Tree_Builder
    from pyfda.libs.compat import QApplication
    from pyfda import pyfda_rc as rc
    logging.basicConfig()  # setup a basic logger

    app = QApplication(sys.argv)
    app.setStyleSheet(rc.qss_rc)

    _ = Tree_Builder()  # TODO_ couldn't this be a function?
    mainw = Input_Fixpoint_Specs(None)
    mainw.show()

    app.exec_()

# test using "python -m pyfda.input_widgets.input_fixpoint_specs"