Commits

Alexey Elfman  committed 8791817

fixes

  • Participants
  • Parent commits 6839a98

Comments (0)

Files changed (7)

 syntax: glob
 *.pyc
 *~
+altf2.egg-info/
+dist/

File altf2/app.py

 class MainForm(QtGui.QMainWindow):
     FIFO_REFRESH_TIMEOUT = 100
     
-    def __init__(self):
-        
+    def __init__(self, app):
+
+        self.app = app
         super(MainForm, self).__init__()
         self.ui = Ui_MainWindow()
         self.ui.setupUi(self)
         self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
+
+        # centering on the desktop
+
+        desktop = self.app.desktop().screenGeometry()
+        
+        x = (desktop.width() - self.window().width()) / 2
+        y = (desktop.height() - self.window().height()) / 3
+        
+        print x, y
+        self.move(x, y)
+        
+        
         self.connect(self.ui.runButton, QtCore.SIGNAL("clicked()"), self.run)
         self.connect(self.ui.command, QtCore.SIGNAL("editTextChanged(QString)"), self.command_changed)
         self.commands = []
         lines = f.read().splitlines()[:50] # save last 100 commands
         f.close()
 
-        if not command in lines:
-            lines.insert(0, command)
+        if command in lines:
+            lines.remove(command)
+            
+        lines.insert(0, command)
 
         f = open(filename, 'w')
         f.write('\n'.join(lines))
     def keyPressEvent(self, event):
         
         key = event.key()
+        print key
         
         if event.modifiers() == QtCore.Qt.NoModifier and key == QtCore.Qt.Key_Escape:
             self.close()
     app = QtGui.QApplication(argv or sys.argv)
     app.setApplicationName("AltF2")
 
-    dialer = MainForm()
+    dialer = MainForm(app)
     dialer.show()
 
     sys.exit(app.exec_())