b35a9655800cd86668fa209cbd6f56ee77f05f4e
[bertos.git] / wizard / BOpenPage.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 #
4 # Copyright 2009 Develer S.r.l. (http://www.develer.com/)
5 # All rights reserved.
6 #
7 # $Id:$
8 #
9 # Author: Lorenzo Berni <duplo@develer.com>
10 #
11
12 import os
13 import pickle
14
15 from PyQt4.QtGui import *
16 from PyQt4.QtCore import *
17
18 from BWizardPage import *
19 import bertos_utils
20
21 from const import *
22
23 class BOpenPage(BWizardPage):
24     """
25     Initial page of the wizard. Permit to select the project name and the directory
26     where the project will be created.
27     """
28     
29     def __init__(self):
30         BWizardPage.__init__(self, UI_LOCATION + "/project_select.ui")
31         self.setTitle(self.tr("Open an existing BeRTOS project"))
32     
33     ## Overloaded BWizardPage methods ##
34     
35     def reloadData(self):
36         project = unicode(QFileDialog.getOpenFileName(self, self.tr("Open project file"), os.path.expanduser("~"), self.tr("Project file (project.bertos)")))
37         if project == "":
38             QApplication.instance().quit()
39         else:
40             QApplication.instance().project = pickle.loads(open(project, "r").read())
41             self.pageContent.nameLabel.setText(os.path.basename(project.replace(os.sep + "project.bertos", "")))
42             self.pageContent.dirLabel.setText(project)
43     
44     ####
45