fe
This commit is contained in:
parent
c5dc669b5e
commit
f9e3422898
5 changed files with 28 additions and 34 deletions
26
__main__.py
26
__main__.py
|
@ -86,10 +86,22 @@ class MainWindow(QtGui.QMainWindow, ui.Ui_MainWindow):
|
|||
self.setupUi(self)
|
||||
self.lineEdit.returnPressed.connect(self.input_characters)
|
||||
self.pushButton.clicked.connect(self.input_characters)
|
||||
self.pushButton_2.clicked.connect(self.clear_input)
|
||||
self.action_About.triggered.connect(self.show_about)
|
||||
|
||||
def clear_input(self):
|
||||
self.label_2.setText("")
|
||||
self.lineEdit.clear()
|
||||
|
||||
def show_about(self):
|
||||
about_dialog = QtGui.QWidget()
|
||||
about_dialog_ui = ui2.Ui_Dialog()
|
||||
about_dialog_ui.setupUi(about_dialog)
|
||||
about_dialog.show()
|
||||
|
||||
def show_result(self,char_code):
|
||||
result = ""
|
||||
header = '<table style=\"vertical-align:top;\">'
|
||||
header = "<table style=\"vertical-align:top;\"><tr><td colspan=2>查碼結果:</td></tr>"
|
||||
result = header + result
|
||||
|
||||
for (char,code) in char_code:
|
||||
|
@ -108,9 +120,13 @@ class MainWindow(QtGui.QMainWindow, ui.Ui_MainWindow):
|
|||
|
||||
def input_characters(self):
|
||||
import re
|
||||
|
||||
characters = self.lineEdit.text()
|
||||
chinese_char_pattern = re.compile("^[\u2f00-\u2fd5\u4e00-\u9fcc\u3400-\u4db5\u20000-\u2a6d6\u2a700-\u2b734\u2b740-\u2b81d\u2b820-\u2cea1]+$")
|
||||
|
||||
#some CJK ext B,C,etc arerepensented in utf16 in pyqt qlineedit.
|
||||
#convert it to utf8
|
||||
#characters = characters.encode(encoding='utf-16',errors='surrogatepass').decode('utf-8')
|
||||
#print('\\u'+"\\u".join("{:x}".format(ord(c)) for c in characters))
|
||||
chinese_char_pattern = re.compile("^[一-鿌㐀-䶵𠀷𠂁𠁍]+$",re.UNICODE)
|
||||
is_chinese_chars = chinese_char_pattern.match(characters)
|
||||
|
||||
if is_chinese_chars:
|
||||
|
@ -121,8 +137,8 @@ class MainWindow(QtGui.QMainWindow, ui.Ui_MainWindow):
|
|||
|
||||
def main():
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
form = MainWindow()
|
||||
form.show()
|
||||
main_window = MainWindow()
|
||||
main_window.show()
|
||||
app.exec_()
|
||||
|
||||
|
||||
|
|
BIN
__pycache__/ui.cpython-34.pyc
Normal file
BIN
__pycache__/ui.cpython-34.pyc
Normal file
Binary file not shown.
BIN
__pycache__/ui2.cpython-34.pyc
Normal file
BIN
__pycache__/ui2.cpython-34.pyc
Normal file
Binary file not shown.
19
ui.py
19
ui.py
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Form implementation generated from reading ui file 'ui.ui'
|
||||
#
|
||||
# Created: Fri Apr 1 23:13:43 2016
|
||||
# Created: Sat Apr 2 15:29:18 2016
|
||||
# by: PyQt4 UI code generator 4.10.4
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
@ -123,18 +123,7 @@ class Ui_MainWindow(object):
|
|||
self.label.setText(_translate("MainWindow", "輸入文字", None))
|
||||
self.pushButton.setText(_translate("MainWindow", "查詢", None))
|
||||
self.pushButton_2.setText(_translate("MainWindow", "清空", None))
|
||||
self.label_2.setText(_translate("MainWindow", "<html><head/><body><p>您查詢的行列碼為:\n"
|
||||
"<table style=\"vertical-align:top;\">\n"
|
||||
"<tr>\n"
|
||||
"<td><span style=\" font-size:18pt;\">越</span></td>\n"
|
||||
"<td >4^3v1^2v<br/>4^1^</td>\n"
|
||||
"</tr>\n"
|
||||
"<tr>\n"
|
||||
"<td><span style=\" font-size:18pt;\">的</span></td>\n"
|
||||
"<td >9-0^9-6-<br/>5^</td>\n"
|
||||
"</tr>\n"
|
||||
"</table>\n"
|
||||
"</html>", None))
|
||||
self.menu_Help.setTitle(_translate("MainWindow", "&Help", None))
|
||||
self.action_About.setText(_translate("MainWindow", "&About...", None))
|
||||
self.label_2.setText(_translate("MainWindow", "<html><head/><body><p><br/></p></body></html>", None))
|
||||
self.menu_Help.setTitle(_translate("MainWindow", "說明 (&H)", None))
|
||||
self.action_About.setText(_translate("MainWindow", "關於 findarray30code (&A)", None))
|
||||
|
||||
|
|
17
ui.ui
17
ui.ui
|
@ -120,18 +120,7 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>您查詢的行列碼為:
|
||||
<table style="vertical-align:top;">
|
||||
<tr>
|
||||
<td><span style=" font-size:18pt;">越</span></td>
|
||||
<td >4^3v1^2v<br/>4^1^</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span style=" font-size:18pt;">的</span></td>
|
||||
<td >9-0^9-6-<br/>5^</td>
|
||||
</tr>
|
||||
</table>
|
||||
</html></string>
|
||||
<string></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::AutoText</enum>
|
||||
|
@ -169,7 +158,7 @@
|
|||
</property>
|
||||
<widget class="QMenu" name="menu_Help">
|
||||
<property name="title">
|
||||
<string>&Help</string>
|
||||
<string>說明 (&H)</string>
|
||||
</property>
|
||||
<addaction name="action_About"/>
|
||||
</widget>
|
||||
|
@ -178,7 +167,7 @@
|
|||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="action_About">
|
||||
<property name="text">
|
||||
<string>&About...</string>
|
||||
<string>關於 findarray30code (&A)</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
|
|
Loading…
Reference in a new issue