Commits

Atsushi Odagiri committed 051cf5e

save file.

Comments (0)

Files changed (2)

notepad/mainwindow.ui

    <property name="text">
     <string>Open</string>
    </property>
+   <property name="shortcut">
+    <string>Ctrl+O</string>
+   </property>
   </action>
   <action name="actionSave">
    <property name="text">
     <string>Save</string>
    </property>
+   <property name="shortcut">
+    <string>Ctrl+S</string>
+   </property>
   </action>
   <action name="actionSave_As">
    <property name="text">

notepad/notepad.py

         f.close()
         self.filename = filename
 
+    @QtCore.pyqtSlot()
+    def on_actionSave_triggered(self):
+        if self.filename is None:
+            return
+        text = unicode(self.textEdit.toPlainText())
+        f = open(self.filename, "w")
+        f.write(text.encode(self.encoding))
+        f.close()
+
+
 import sys
 def main():
     app = QtGui.QApplication(sys.argv)