Permalink
Browse files

accuracy spin button in stat window

  • Loading branch information...
1 parent 1c015df commit 4d9a33e4b0af48607d2adb5dba770fce5f3d7aac @baverman committed Feb 10, 2011
Showing with 124 additions and 7 deletions.
  1. +112 −0 typetrainer/ui/stat.glade
  2. +12 −7 typetrainer/ui/stat.py
View
@@ -0,0 +1,112 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkWindow" id="window">
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Speed statistic</property>
+ <property name="role">TypetrainerStat</property>
+ <property name="modal">True</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="default_width">800</property>
+ <property name="default_height">400</property>
+ <property name="type_hint">dialog</property>
+ <child>
+ <object class="GtkVBox" id="vbox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkFrame" id="frame">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child type="label_item">
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="spacing">15</property>
+ <child>
+ <object class="GtkComboBox" id="tutor_cb">
+ <property name="visible">True</property>
+ <property name="model">tutor_ls</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="spacing">15</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Accuracy:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="acc_sbt">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">&#x25CF;</property>
+ <property name="adjustment">acc_adj</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkAdjustment" id="acc_adj">
+ <property name="value">97</property>
+ <property name="lower">50</property>
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">5</property>
+ <signal name="value_changed" handler="on_acc_adj_value_changed"/>
+ </object>
+ <object class="GtkListStore" id="tutor_ls">
+ <columns>
+ <!-- column-name md5 -->
+ <column type="gchararray"/>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+</interface>
View
@@ -2,6 +2,9 @@
import gtk
+from . import BuilderAware
+from ..util import join_to_file_dir
+
class StatDrawer(gtk.DrawingArea):
__gsignals__ = { "expose-event": "override" }
@@ -114,18 +117,20 @@ def draw_label(self, cr, label, x, y, w, h, xalign, yalign):
cr.show_text(label)
-class StatWindow(object):
+class StatWindow(BuilderAware):
+ """glade-file: stat.glade"""
+
def __init__(self, parent, stat):
+ BuilderAware.__init__(self, join_to_file_dir(__file__, 'stat.glade'))
+
self.stat = stat
- self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
- self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
- self.window.set_default_size(600, 400)
- self.window.set_modal(True)
self.window.set_transient_for(parent)
self.drawer = StatDrawer()
- self.window.add(self.drawer)
+ self.frame.add(self.drawer)
- self.drawer.set_data(stat.get('en.basic', 97))
+ self.acc_adj.value = 97
+ def on_acc_adj_value_changed(self, adj):
+ self.drawer.set_data(self.stat.get('en.basic', adj.value))

0 comments on commit 4d9a33e

Please sign in to comment.