Example #1
0
 def __init__(self, parent=None):
     qt.QWidget.__init__(self, parent)
     #####################
     hbox = HBox()
     spin = qt.QSpinBox()
     spin.setRange(1, 999)
     spin.setSingleStep(1)
     spin.setLayoutDirection(qc.Qt.LeftToRight)
     spin.setValue(ui.mcalHeight)
     self.connect(spin, qc.SIGNAL('valueChanged (int)'), self.heightSpinChanged)
     hbox.addWidget(qt.QLabel(_('Height')))
     hbox.addWidget(spin)
     MainWinItem.__init__(self, 'monthCal', _('Month Calendar'), optionsWidget=hbox)
     self.setFixedHeight(ui.mcalHeight)
     self.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)
     ######################
     ## self.supports_alpha = ## ??????????
     #self.kTime = 0
     ######################
     ## Define drag and drop
     ######################
     self.myKeys = (
         qc.Qt.Key_Up, qc.Qt.Key_Down, qc.Qt.Key_Right, qc.Qt.Key_Left, qc.Qt.Key_Space, qc.Qt.Key_Home, qc.Qt.Key_End,
         qc.Qt.Key_PageUp, qc.Qt.Key_PageDown, qc.Qt.Key_Menu, qc.Qt.Key_F10, qc.Qt.Key_M
     )
     ######################
     self.updateTextWidth()
Example #2
0
 def __init__(self, shownCals=ui.shownCals, parent=None):
     qt.QWidget.__init__(self, parent)
     #####################
     if shownCals[0]['font']==None:
         shownCals[0]['font'] = ui.fontDefault
     (name, bold, underline, size) = ui.fontDefault
     for item in shownCals[1:]:
         if item['font']==None:
             item['font'] = (name, bold, underline, int(size*0.6))
     del name, bold, underline, size
     #########################
     hbox = HBox()
     spin = qt.QSpinBox()
     spin.setRange(1, 999)
     spin.setSingleStep(1)
     spin.setLayoutDirection(qc.Qt.LeftToRight)
     spin.setValue(ui.mcalHeight)
     self.connect(spin, qc.SIGNAL('valueChanged (int)'), self.heightSpinChanged)
     hbox.addWidget(qt.QLabel(_('Height')))
     hbox.addWidget(spin)
     MainWinItem.__init__(self, 'monthCal', _('Month Calendar'), optionsWidget=hbox)
     self.setFixedHeight(ui.mcalHeight)
     self.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)
     ######################
     self.shownCals = shownCals
     ## self.supports_alpha = ## ??????????
     #self.kTime = 0
     ######################
     ## Define drag and drop
     ######################
     self.myKeys = (
         qc.Qt.Key_Up, qc.Qt.Key_Down, qc.Qt.Key_Right, qc.Qt.Key_Left, qc.Qt.Key_Space, qc.Qt.Key_Home, qc.Qt.Key_End,
         qc.Qt.Key_PageUp, qc.Qt.Key_PageDown, qc.Qt.Key_Menu, qc.Qt.Key_F10, qc.Qt.Key_M
     )
     ######################
     self.updateTextWidth()
langNameList = []
langCodeList = []

langDefaultCode = ""

win = qt.QDialog()
win.setWindowTitle(APP_DESC + " - First Run")

win.setWindowIcon(qt.QIcon("%s/starcal2.png" % pixDir))
vboxL = qt.QVBoxLayout()
vboxL.setMargin(0)
win.setLayout(vboxL)

langHbox = HBox()
langHbox.addWidget(qt.QLabel("Select Language:"))


importCheckb = None
oldVersion = getOldVersion()
if oldVersion and "1.5.0" < oldVersion < "1.6.0":  ## FIXME
    importCheckb = qt.QCheckBox("Import configurations from %s %s" % (APP_DESC, oldVersion))
    importCheckb.connect(
        importCheckb, qc.SIGNAL("stateChanged (int)"), lambda state: langHbox.setEnabled(state != qc.Qt.Checked)
    )
    importCheckb.setCheckState(qc.Qt.Checked)
    vboxL.addWidget(importCheckb)


langCombo = qt.QComboBox()
for fname in os.listdir(langDir):
Example #4
0
    def __init__(self, maxResults=200):
        #qt.QWidget.__init__(self, None, qc.Qt.Tool)## FIXME
        qt.QDialog.__init__(self, None, qc.Qt.Tool)## FIXME
        self.maxResults = maxResults
        self.vbox = qt.QVBoxLayout()
        self.vbox.setMargin(0)
        self.setLayout(self.vbox)
        ###############
        hbox = HBox()
        hbox.addWidget(qt.QLabel(_('Search Cities:')))
        entry = qt.QLineEdit()
        hbox.addWidget(entry)
        entry.changeEvent = self.entryChanged
        self.vbox.addWidget(hbox)
        ######################
        treev = qt.QTreeWidget()
        treev.setColumnCount(2)
        treev.setHeaderLabels([_('Index'), _('City'),])
        treev.hideColumn(0)
        #treev.set_headers_clickable(False)
        #treev.set_headers_visible(False)
        self.vbox.addWidget(treev)
        self.treev = treev
        treev.selectionChanged = self.treevSelectionChanged
        #treev.set_search_column(1)
        #########
        lines = file(dataDir+'/locations.txt').read().split('\n')
        cityData = []
        country = ''
        for l in lines:
            p = l.split('\t')
            if len(p)<2:
                #print p
                continue
            if p[0]=='':
                if p[1]=='':
                    city, lat, lng = p[2:5]
                    #if country=='Iran':
                    #    print city
                    if len(p)>4:
                        cityData.append((
                            country + '/' + city,
                            _(country) + '/' + _(city),
                            float(lat),
                            float(lng)
                        ))
                    else:
                        print country, p
                else:
                    country = p[1]

        self.cityData = cityData
        self.updateList()
        ###########
        gbox = qt.QGroupBox(_('Edit Manually'))
        gboxLay = qt.QVBoxLayout()
        gboxLay.setMargin(0)## FIXME
        gbox.setLayout(gboxLay)
        gbox.setCheckable(True)
        self.connect(gbox, qc.SIGNAL('toggled (bool)'), self.editCheckbToggled)
        self.gboxEdit = gbox
        vbox = VBox()
        #group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        #####
        hbox = HBox()
        label = qt.QLabel(_('Name:'))
        hbox.addWidget(label)
        #group.add_widget(label)
        #label.set_alignment(0, 0.5)
        entry = qt.QLineEdit()
        hbox.addWidget(entry)
        vbox.addWidget(hbox)
        self.entry_edit_name = entry
        ####
        hbox = HBox()
        label = qt.QLabel(_('Latitude:'))
        hbox.addWidget(label)
        #group.add_widget(label)
        #label.set_alignment(0, 0.5)
        ####
        spin = qt.QDoubleSpinBox()
        spin.setSingleStep(1)
        spin.setRange(-180, 180)
        spin.setDecimals(3)
        spin.setLayoutDirection(qc.Qt.LeftToRight)
        hbox.addWidget(spin)
        vbox.addWidget(hbox)
        self.spin_lat = spin
        ####
        hbox = HBox()
        label = qt.QLabel(_('Longitude:'))
        hbox.addWidget(label)
        #group.add_widget(label)
        spin = qt.QDoubleSpinBox()
        spin.setSingleStep(1)
        spin.setRange(-180, 180)
        spin.setDecimals(3)
        spin.setLayoutDirection(qc.Qt.LeftToRight)
        hbox.addWidget(spin)
        vbox.addWidget(hbox)
        self.spin_lng = spin
        ####
        hbox = HBox()
        self.lowerLabel = qt.QLabel('')
        # self.lowerLabel.setSizePolicy Expandig ## FIXME
        hbox.addWidget(self.lowerLabel)
        #self.lowerLabel.set_alignment(0, 0.5)
        button = qt.QPushButton(_('Calculate Nearest City'))
        self.connect(button, qc.SIGNAL('clicked ()'), self.calcClicked)
        hbox.addWidget(button)
        vbox.addWidget(hbox)
        ####
        vbox.setEnabled(False)
        gboxLay.addWidget(vbox)
        self.vbox_edit = vbox
        self.vbox.addWidget(gbox)
        #######
        bbox = qt.QDialogButtonBox(qc.Qt.Horizontal)
        cancelB = bbox.addButton(qt.QDialogButtonBox.Cancel)
        okB = bbox.addButton(qt.QDialogButtonBox.Ok)
        if autoLocale:
            cancelB.setText(_('_Cancel'))
            #cancelB.setIcon(qt.QIcon('cancel.png'))
            okB.setText(_('_OK'))
            #okB.setIcon(qt.QIcon('ok.png'))
            #okB.grab_default()#?????????
            #okB.grab_focus()#?????????
        ## ???????????????
        self.connect(bbox, qc.SIGNAL('rejected()'), lambda: self.reject())
        self.connect(bbox, qc.SIGNAL('accepted()'), lambda: self.accept())
        #self.connect(cancelB, qc.SIGNAL('clicked()'), self.reject)
        #self.connect(okB, qc.SIGNAL('clicked()'), self.accept)
        '''
        cancelB = self.add_button(gtk.STOCK_CANCEL, self.EXIT_CANCEL)
        okB = self.add_button(gtk.STOCK_OK, self.EXIT_OK)
        #if autoLocale:
        cancelB.setText(_('_Cancel'))
        cancelB.set_image(gtk.image_new_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_BUTTON))
        okB.setText(_('_OK'))
        okB.set_image(gtk.image_new_from_stock(gtk.STOCK_OK, gtk.ICON_SIZE_BUTTON))
        '''
        self.vbox.addWidget(bbox)
Example #5
0
 def makeWidget(self):
     self.confDialog = qt.QDialog()
     self.confDialog.setWindowTitle(_('Pray Times') + ' - ' + _('Configuration'))
     self.confDialog.vbox = qt.QVBoxLayout()
     self.confDialog.vbox.setMargin(0)
     self.confDialog.setLayout(self.confDialog.vbox)
     #group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
     ###
     hbox = HBox()
     label = qt.QLabel(_('Location'))
     #group.add_widget(label)
     #label.set_alignment(0, 0.5)
     hbox.addWidget(label)
     self.locButton = LocationButton(self.locName, self.ptObj.lat, self.ptObj.lng)
     hbox.addWidget(self.locButton)
     self.confDialog.vbox.addWidget(hbox)
     ###
     hbox = HBox()
     label = qt.QLabel(_('Calculation Method'))
     #group.add_widget(label)
     #label.set_alignment(0, 0.5)
     hbox.addWidget(label)
     self.methodCombo = qt.QComboBox()
     for methodObj in methodsList:
         self.methodCombo.addItem(_(methodObj.desc))
     hbox.addWidget(self.methodCombo)
     self.confDialog.vbox.addWidget(hbox)
     #######
     treev = qt.QTreeWidget()
     treev.setColumnCount(3)
     treev.setHeaderLabels([_('Enable'), _('Description'), _('Name')])
     treev.hideColumn(2)
     ###
     self.shownTimesTreewidget = treev
     for name in timeNames:
         item = qt.QTreeWidgetItem(['', _(name.capitalize()), name])
         item.setCheckState(0, True)
         treev.addTopLevelItem(item)
     gbox = qt.QGroupBox(_('Shown Times'))
     gboxLay = qt.QVBoxLayout()
     gboxLay.setMargin(0)## FIXME
     gbox.setLayout(gboxLay)
     gboxLay.addWidget(treev)
     self.confDialog.vbox.addWidget(gbox)
     ######
     hbox = HBox()
     hbox.addWidget(qt.QLabel(_('Imsak')))
     spin = qt.QSpinBox()
     spin.setSingleStep(1)
     spin.setRange(0, 99)
     spin.setLayoutDirection(qc.Qt.LeftToRight)
     self.imsakSpin = spin
     hbox.addWidget(spin)
     hbox.addWidget(qt.QLabel(' '+_('minutes before fajr')))
     self.confDialog.vbox.addWidget(hbox)
     ######
     self.updateConfWidget()
     #######
     bbox = qt.QDialogButtonBox(qc.Qt.Horizontal)
     cancelB = bbox.addButton(qt.QDialogButtonBox.Cancel)
     okB = bbox.addButton(qt.QDialogButtonBox.Ok)
     if autoLocale:
         cancelB.setText(_('_Cancel'))
         #cancelB.setIcon(qt.QIcon('cancel.png'))
         okB.setText(_('_OK'))
         #okB.setIcon(qt.QIcon('ok.png'))
     self.confDialog.vbox.addWidget(bbox)
     bbox.connect(bbox, qc.SIGNAL('rejected()'), self.confDialogCancel)
     bbox.connect(bbox, qc.SIGNAL('accepted()'), self.confDialogOk)
     ##############
     '''
     submenu = gtk.Menu()
     submenu.add(gtk.MenuItem('Item 1'))
     submenu.add(gtk.MenuItem('Item 2'))
     #self.submenu = submenu
     self.menuitem = gtk.MenuItem('Owghat')
     self.menuitem.set_submenu(submenu)
     self.menuitem.show_all()
     '''
     self.dialog = None
Example #6
0
 def __init__(self, mainWin):
     self.mainWin = mainWin
     self.mcal = mainWin.mcal
     qt.QFileDialog.__init__(self)
     self.setAcceptMode(qt.QFileDialog.AcceptSave)
     self.setFileMode(qt.QFileDialog.AnyFile)## FIXME
     self.setOption(qt.QFileDialog.HideNameFilterDetails)
     self.setWindowTitle(_('Export to %s')%'HTML')
     self.vbox = VBox()
     ########
     hbox = HBox()
     hbox.addWidget(qt.QLabel(_('Month Range')))
     combo = qt.QComboBox()
     for t in ('Current Month', 'Whole Current Year', 'Custom'):
         combo.addItem(_(t))
     hbox.addWidget(combo)
     hbox.addWidget(qt.QLabel(''))
     self.combo = combo
     ###
     hbox2 = HBox()
     hbox2.addWidget(qt.QLabel(_('from month')))
     self.ymBox0 = YearMonthBox()
     hbox2.addWidget(self.ymBox0)
     hbox2.addWidget(qt.QLabel(''))
     hbox2.addWidget(qt.QLabel(_('to month')))
     self.ymBox1 = YearMonthBox()
     hbox2.addWidget(self.ymBox1)
     hbox.addWidget(hbox2)
     self.hbox2 = hbox2
     combo.setCurrentIndex(0)
     self.vbox.addWidget(hbox)
     ########
     self.layout().addWidget(self.vbox, 4, 0, 5, 2)## between rows 4 and 5, between columns 0 and 2 (before buttons)
     ########
     self.connect(combo, qc.SIGNAL('currentIndexChanged (int)'), self.comboChanged)
     self.connect(self, qc.SIGNAL('fileSelected (const QString&)'), self.save)
     try:
         self.setDirectory(deskDir)
     except:## FIXME
         pass