[Pymoul-svn] SF.net SVN: pymoul: [38] pymoul/trunk
Status: Alpha
Brought to you by:
tiran
|
From: <ti...@us...> - 2007-01-16 21:39:46
|
Revision: 38
http://pymoul.svn.sourceforge.net/pymoul/?rev=38&view=rev
Author: tiran
Date: 2007-01-16 13:39:46 -0800 (Tue, 16 Jan 2007)
Log Message:
-----------
More cool work on the UI: time and screen resolution slider
Modified Paths:
--------------
pymoul/trunk/setup_win32.py
pymoul/trunk/src/moul/file/wdysini.py
pymoul/trunk/src/moul/qt/mainwindow.py
pymoul/trunk/src/moul/qt/ui/mainwindow.py
pymoul/trunk/src/moul/qt/ui/mainwindow.ui
pymoul/trunk/src/moul/time/cavern.py
Modified: pymoul/trunk/setup_win32.py
===================================================================
--- pymoul/trunk/setup_win32.py 2007-01-16 20:43:19 UTC (rev 37)
+++ pymoul/trunk/setup_win32.py 2007-01-16 21:39:46 UTC (rev 38)
@@ -38,7 +38,8 @@
packages = ['pytz.zoneinfo']
for tz in ('GMT', 'UTC'):
packages.append('pytz.zoneinfo.%s' % tz)
- for tz in ('America', 'Canada', 'Etc', 'Europe', 'US'):
+ # ('America', 'Canada', 'Etc', 'Europe', 'US'):
+ for tz in ('US',):
packages.append('pytz.zoneinfo.%s.*' % tz)
return packages
# import pytz
@@ -78,11 +79,11 @@
kw['setup_requires'].append(req)
for req in ():
kw['install_requires'].append(req)
- kw['console'] = [
- { "script" : "src/moul/cli/moullauncher.py",
- "icon_resources": [(1, "src/moul/uru.ico")]
- }
- ]
+# kw['console'] = [
+# { "script" : "src/moul/cli/moullauncher.py",
+# "icon_resources": [(1, "src/moul/uru.ico")]
+# }
+# ]
kw.setdefault('options', {})
pexe = kw['options'].setdefault('py2exe', {})
pexe['compressed'] = 100 # compress zip file
Modified: pymoul/trunk/src/moul/file/wdysini.py
===================================================================
--- pymoul/trunk/src/moul/file/wdysini.py 2007-01-16 20:43:19 UTC (rev 37)
+++ pymoul/trunk/src/moul/file/wdysini.py 2007-01-16 21:39:46 UTC (rev 38)
@@ -72,4 +72,23 @@
'Graphics.EnableVSync' : bool,
'Graphics.Shadow.VisibleDistance' : float,
}
+
+ # width, height, w ratio, h ratio
+ _videomodes = VIDEO_MODES
+
+ def getVidModeByIdx(self, idx):
+ """Get video mode by index
+ """
+ return self._videomodes[idx]
+
+ def getVidModeHuman(self, idx):
+ """Human readable vidoe mode by index
+ """
+ #import pdb; pdb.set_trace()
+ return "%ix%i (%i:%i)" % self.getVidModeByIdx(idx)
+ def getVidIdxByMode(self, w, h):
+ for idx, mode in enumerate(self._videomodes):
+ if mode[0] == w and mode[1] == h:
+ return idx
+ raise KeyError("Video mode for %ix%i not found" % (w, h))
Modified: pymoul/trunk/src/moul/qt/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/mainwindow.py 2007-01-16 20:43:19 UTC (rev 37)
+++ pymoul/trunk/src/moul/qt/mainwindow.py 2007-01-16 21:39:46 UTC (rev 38)
@@ -32,7 +32,7 @@
from moul.qt.ui.mainwindow import Ui_MainWindow
from moul.time.cavern import CavernTime
-from moul.time.cavern import TIMEZONE_NAMES
+from moul.file.wdysini import GraphicsIni
class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
def __init__(self):
@@ -41,6 +41,29 @@
self.setupUi(self)
self._timezone_init()
+ self._graphics_init()
+
+ # ************************************************************************
+ # graphics
+ def _graphics_init(self):
+ """init graphics tab
+ """
+ self._graphicsini = GraphicsIni()
+ length = len(self._graphicsini._videomodes) -1
+ self.slid_screenres.setMaximum(length)
+ self.connect(self.slid_screenres, SIGNAL("valueChanged(int)"),
+ self.on_slid_screenres_changed)
+ self.connect(self.slid_screenres, SIGNAL("sliderMoved(int)"),
+ self.on_slid_screenres_changed)
+
+ def on_slid_screenres_changed(self, idx):
+ """SIGNAL: valueChanged (int)
+ """
+ txt = self._graphicsini.getVidModeHuman(idx)
+ self.lb_screenres.setText(QString(txt))
+
+ # ************************************************************************
+ # time zones
def _timezone_init(self):
"""Init time zone tab"""
@@ -52,13 +75,12 @@
self._timezone_timer = timer = QTimer(self)
timer.setInterval(1000) # 1 sec
# TODO: needs optimization? run only when timer tab is active
- self.connect(timer, SIGNAL('timeout()'), self._timezone_update)
+ self.connect(timer, SIGNAL('timeout()'), self.on_timezone_timer_timeout)
timer.start()
- def _timezone_update(self, ct=None):
+ def _timezone_update(self):
"""Update datetime widgets"""
- if ct is None:
- ct = self._caverntime()
+ ct = self._caverntime.info()
self.dt_cavern.setDateTime(ct['cavern']['datetime'])
self.dt_pacific.setDateTime(ct['pacific']['datetime'])
@@ -70,3 +92,10 @@
off = ct['pacific']['utcoffset']
txt = "UTC %s%i" % (off[0], abs(off[1]))
self.lb_pacific_utc.setText(QString(txt))
+
+ def on_timezone_timer_timeout(self):
+ """SIGNAL: QTimer timeout
+ """
+ ct = self._caverntime()
+ self.dt_cavern.setDateTime(ct['cavern'])
+ self.dt_pacific.setDateTime(ct['pacific'])
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-01-16 20:43:19 UTC (rev 37)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.py 2007-01-16 21:39:46 UTC (rev 38)
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'src\moul\qt\ui\mainwindow.ui'
#
-# Created: Tue Jan 16 21:38:16 2007
+# Created: Tue Jan 16 22:34:20 2007
# by: PyQt4 UI code generator 4.1.1
#
# WARNING! All changes made in this file will be lost!
@@ -65,12 +65,6 @@
self.label.setPixmap(QtGui.QPixmap(":/resources/moul_logo.png"))
self.label.setObjectName("label")
- self.buttonbox_rresavcl = QtGui.QDialogButtonBox(self.centralwidget)
- self.buttonbox_rresavcl.setGeometry(QtCore.QRect(10,480,441,32))
- self.buttonbox_rresavcl.setOrientation(QtCore.Qt.Horizontal)
- self.buttonbox_rresavcl.setStandardButtons(QtGui.QDialogButtonBox.Close|QtGui.QDialogButtonBox.NoButton|QtGui.QDialogButtonBox.Reset|QtGui.QDialogButtonBox.Save)
- self.buttonbox_rresavcl.setObjectName("buttonbox_rresavcl")
-
self.tabWidget = QtGui.QTabWidget(self.centralwidget)
self.tabWidget.setGeometry(QtCore.QRect(5,100,450,375))
self.tabWidget.setTabPosition(QtGui.QTabWidget.North)
@@ -92,21 +86,20 @@
self.vboxlayout.setSpacing(6)
self.vboxlayout.setObjectName("vboxlayout")
- self.horizontalSlider = QtGui.QSlider(self.verticalLayout_2)
- self.horizontalSlider.setMaximum(11)
- self.horizontalSlider.setPageStep(1)
- self.horizontalSlider.setSliderPosition(0)
- self.horizontalSlider.setTracking(False)
- self.horizontalSlider.setOrientation(QtCore.Qt.Horizontal)
- self.horizontalSlider.setTickPosition(QtGui.QSlider.TicksBelow)
- self.horizontalSlider.setTickInterval(1)
- self.horizontalSlider.setObjectName("horizontalSlider")
- self.vboxlayout.addWidget(self.horizontalSlider)
+ self.slid_screenres = QtGui.QSlider(self.verticalLayout_2)
+ self.slid_screenres.setMaximum(10)
+ self.slid_screenres.setPageStep(1)
+ self.slid_screenres.setSliderPosition(0)
+ self.slid_screenres.setOrientation(QtCore.Qt.Horizontal)
+ self.slid_screenres.setTickPosition(QtGui.QSlider.TicksBelow)
+ self.slid_screenres.setTickInterval(1)
+ self.slid_screenres.setObjectName("slid_screenres")
+ self.vboxlayout.addWidget(self.slid_screenres)
- self.label_resolution = QtGui.QLabel(self.verticalLayout_2)
- self.label_resolution.setAlignment(QtCore.Qt.AlignCenter)
- self.label_resolution.setObjectName("label_resolution")
- self.vboxlayout.addWidget(self.label_resolution)
+ self.lb_screenres = QtGui.QLabel(self.verticalLayout_2)
+ self.lb_screenres.setAlignment(QtCore.Qt.AlignCenter)
+ self.lb_screenres.setObjectName("lb_screenres")
+ self.vboxlayout.addWidget(self.lb_screenres)
self.groupBox_2 = QtGui.QGroupBox(self.tab_graphics)
self.groupBox_2.setGeometry(QtCore.QRect(10,90,430,250))
@@ -290,6 +283,10 @@
self.tab_time = QtGui.QWidget()
self.tab_time.setObjectName("tab_time")
+ self.gb_dnitime = QtGui.QGroupBox(self.tab_time)
+ self.gb_dnitime.setGeometry(QtCore.QRect(10,130,431,211))
+ self.gb_dnitime.setObjectName("gb_dnitime")
+
self.gb_caverntime = QtGui.QGroupBox(self.tab_time)
self.gb_caverntime.setGeometry(QtCore.QRect(10,10,431,111))
self.gb_caverntime.setObjectName("gb_caverntime")
@@ -330,10 +327,6 @@
self.lb_pacific_utc = QtGui.QLabel(self.gridLayout)
self.lb_pacific_utc.setObjectName("lb_pacific_utc")
self.gridlayout.addWidget(self.lb_pacific_utc,1,2,1,1)
-
- self.gb_dnitime = QtGui.QGroupBox(self.tab_time)
- self.gb_dnitime.setGeometry(QtCore.QRect(10,130,431,211))
- self.gb_dnitime.setObjectName("gb_dnitime")
self.tabWidget.addTab(self.tab_time,"")
self.tab_4 = QtGui.QWidget()
@@ -344,6 +337,12 @@
self.label_6.setAlignment(QtCore.Qt.AlignCenter)
self.label_6.setObjectName("label_6")
self.tabWidget.addTab(self.tab_4,"")
+
+ self.buttonbox_rresavcl = QtGui.QDialogButtonBox(self.centralwidget)
+ self.buttonbox_rresavcl.setGeometry(QtCore.QRect(10,480,441,32))
+ self.buttonbox_rresavcl.setOrientation(QtCore.Qt.Horizontal)
+ self.buttonbox_rresavcl.setStandardButtons(QtGui.QDialogButtonBox.Close|QtGui.QDialogButtonBox.NoButton|QtGui.QDialogButtonBox.Reset|QtGui.QDialogButtonBox.Save)
+ self.buttonbox_rresavcl.setObjectName("buttonbox_rresavcl")
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtGui.QStatusBar(MainWindow)
@@ -356,10 +355,10 @@
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
- MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
+ MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "Tool for Myst Online", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton.setText(QtGui.QApplication.translate("MainWindow", "Configure", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Screen Resolution", None, QtGui.QApplication.UnicodeUTF8))
- self.label_resolution.setText(QtGui.QApplication.translate("MainWindow", "800x600 (4:3)", None, QtGui.QApplication.UnicodeUTF8))
+ self.lb_screenres.setText(QtGui.QApplication.translate("MainWindow", "800x600 (4:3)", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox_2.setTitle(QtGui.QApplication.translate("MainWindow", "Quality", None, QtGui.QApplication.UnicodeUTF8))
self.label_20.setText(QtGui.QApplication.translate("MainWindow", "Texture:", None, QtGui.QApplication.UnicodeUTF8))
self.label_21.setText(QtGui.QApplication.translate("MainWindow", "Low", None, QtGui.QApplication.UnicodeUTF8))
@@ -377,12 +376,12 @@
self.label_7.setText(QtGui.QApplication.translate("MainWindow", "Ultra", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_graphics), QtGui.QApplication.translate("MainWindow", "Graphis", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_audio), QtGui.QApplication.translate("MainWindow", "Audio", None, QtGui.QApplication.UnicodeUTF8))
+ self.gb_dnitime.setTitle(QtGui.QApplication.translate("MainWindow", "D\'ni time", None, QtGui.QApplication.UnicodeUTF8))
self.gb_caverntime.setTitle(QtGui.QApplication.translate("MainWindow", "Time zones", None, QtGui.QApplication.UnicodeUTF8))
self.label_4.setText(QtGui.QApplication.translate("MainWindow", "Cavern time:", None, QtGui.QApplication.UnicodeUTF8))
self.lb_cavern_utc.setText(QtGui.QApplication.translate("MainWindow", "UTC", None, QtGui.QApplication.UnicodeUTF8))
self.label_5.setText(QtGui.QApplication.translate("MainWindow", "Pacific time:", None, QtGui.QApplication.UnicodeUTF8))
self.lb_pacific_utc.setText(QtGui.QApplication.translate("MainWindow", "UTC", None, QtGui.QApplication.UnicodeUTF8))
- self.gb_dnitime.setTitle(QtGui.QApplication.translate("MainWindow", "D\'ni time", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_time), QtGui.QApplication.translate("MainWindow", "Time", None, QtGui.QApplication.UnicodeUTF8))
self.label_6.setText(QtGui.QApplication.translate("MainWindow", "pyMoul tools", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_4), QtGui.QApplication.translate("MainWindow", "About", None, QtGui.QApplication.UnicodeUTF8))
Modified: pymoul/trunk/src/moul/qt/ui/mainwindow.ui
===================================================================
--- pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-01-16 20:43:19 UTC (rev 37)
+++ pymoul/trunk/src/moul/qt/ui/mainwindow.ui 2007-01-16 21:39:46 UTC (rev 38)
@@ -22,7 +22,7 @@
</sizepolicy>
</property>
<property name="windowTitle" >
- <string>MainWindow</string>
+ <string>Tool for Myst Online</string>
</property>
<property name="windowIcon" >
<iconset resource="moulqt.qrc" >:/resources/uru_icon_32x32.png</iconset>
@@ -100,22 +100,6 @@
<pixmap resource="moulqt.qrc" >:/resources/moul_logo.png</pixmap>
</property>
</widget>
- <widget class="QDialogButtonBox" name="buttonbox_rresavcl" >
- <property name="geometry" >
- <rect>
- <x>10</x>
- <y>480</y>
- <width>441</width>
- <height>32</height>
- </rect>
- </property>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons" >
- <set>QDialogButtonBox::Close|QDialogButtonBox::NoButton|QDialogButtonBox::Reset|QDialogButtonBox::Save</set>
- </property>
- </widget>
<widget class="QTabWidget" name="tabWidget" >
<property name="geometry" >
<rect>
@@ -164,9 +148,9 @@
<number>6</number>
</property>
<item>
- <widget class="QSlider" name="horizontalSlider" >
+ <widget class="QSlider" name="slid_screenres" >
<property name="maximum" >
- <number>11</number>
+ <number>10</number>
</property>
<property name="pageStep" >
<number>1</number>
@@ -174,9 +158,6 @@
<property name="sliderPosition" >
<number>0</number>
</property>
- <property name="tracking" >
- <bool>false</bool>
- </property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
@@ -189,7 +170,7 @@
</widget>
</item>
<item>
- <widget class="QLabel" name="label_resolution" >
+ <widget class="QLabel" name="lb_screenres" >
<property name="text" >
<string>800x600 (4:3)</string>
</property>
@@ -564,6 +545,19 @@
<attribute name="title" >
<string>Time</string>
</attribute>
+ <widget class="QGroupBox" name="gb_dnitime" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>130</y>
+ <width>431</width>
+ <height>211</height>
+ </rect>
+ </property>
+ <property name="title" >
+ <string>D'ni time</string>
+ </property>
+ </widget>
<widget class="QGroupBox" name="gb_caverntime" >
<property name="geometry" >
<rect>
@@ -643,19 +637,6 @@
</layout>
</widget>
</widget>
- <widget class="QGroupBox" name="gb_dnitime" >
- <property name="geometry" >
- <rect>
- <x>10</x>
- <y>130</y>
- <width>431</width>
- <height>211</height>
- </rect>
- </property>
- <property name="title" >
- <string>D'ni time</string>
- </property>
- </widget>
</widget>
<widget class="QWidget" name="tab_4" >
<attribute name="title" >
@@ -679,6 +660,22 @@
</widget>
</widget>
</widget>
+ <widget class="QDialogButtonBox" name="buttonbox_rresavcl" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>480</y>
+ <width>441</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Close|QDialogButtonBox::NoButton|QDialogButtonBox::Reset|QDialogButtonBox::Save</set>
+ </property>
+ </widget>
</widget>
<widget class="QStatusBar" name="statusbar" />
</widget>
@@ -697,8 +694,8 @@
<y>494</y>
</hint>
<hint type="destinationlabel" >
- <x>46</x>
- <y>661</y>
+ <x>42</x>
+ <y>529</y>
</hint>
</hints>
</connection>
Modified: pymoul/trunk/src/moul/time/cavern.py
===================================================================
--- pymoul/trunk/src/moul/time/cavern.py 2007-01-16 20:43:19 UTC (rev 37)
+++ pymoul/trunk/src/moul/time/cavern.py 2007-01-16 21:39:46 UTC (rev 38)
@@ -119,6 +119,9 @@
>>> ct = CavernTime()
>>> result = ct()
+ >>> 'cavern' in result, 'pacific' in result
+ (True, True)
+ >>> result = ct.info()
>>> 'utc' in result
True
@@ -169,11 +172,18 @@
if utc_dt is None:
utc_dt = self._utcnow()
return tz.normalize(utc_dt.astimezone(tz))
-
+
def __call__(self):
now = self._utcnow()
result = {}
for id, tz in (('cavern', self._cavern), ('pacific', self._pacific)):
+ result[id] = self._normalize(tz, now)
+ return result
+
+ def info(self):
+ now = self._utcnow()
+ result = {}
+ for id, tz in (('cavern', self._cavern), ('pacific', self._pacific)):
info = result.setdefault(id, {})
utcoffset = td2int(tz.utcoffset(now))
signum = utcoffset < 0 and '-' or '+'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|