summaryrefslogtreecommitdiff
path: root/src/subcircuit/openSub.py
blob: 0e0906c08f6d74b8b55e1404e912fbd1b98b5840 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from PyQt4 import QtGui
from configuration.Appconfig import Appconfig
from projManagement.Worker import WorkerThread
import os


# This class is called when User clicks on Edit Subcircuit Button.
class openSub(QtGui.QWidget):
    """
    It opens the existing subcircuit projects that are present in
    Subcircuit directory.
    """

    def __init__(self):
        super(openSub, self).__init__()
        self.obj_appconfig = Appconfig()

    def body(self):

        init_path = '../../'
        if os.name == 'nt':
            init_path = ''

        self.editfile = str(
            QtGui.QFileDialog.getExistingDirectory(
                None, "Open File", init_path + "library/SubcircuitLibrary"))
        if self.editfile:
            self.obj_Appconfig = Appconfig()
            self.obj_Appconfig.current_subcircuit['SubcircuitName'] \
                = self.editfile

            self.schname = os.path.basename(self.editfile)
            self.editfile = os.path.join(self.editfile, self.schname)
            self.cmd = "eeschema " + self.editfile + ".sch "
            self.obj_workThread = WorkerThread(self.cmd)
            self.obj_workThread.start()