add
This commit is contained in:
parent
47662c1094
commit
c5dc669b5e
3 changed files with 79 additions and 31 deletions
23
__main__.py
23
__main__.py
|
@ -87,16 +87,35 @@ class MainWindow(QtGui.QMainWindow, ui.Ui_MainWindow):
|
||||||
self.lineEdit.returnPressed.connect(self.input_characters)
|
self.lineEdit.returnPressed.connect(self.input_characters)
|
||||||
self.pushButton.clicked.connect(self.input_characters)
|
self.pushButton.clicked.connect(self.input_characters)
|
||||||
|
|
||||||
|
def show_result(self,char_code):
|
||||||
|
result = ""
|
||||||
|
header = '<table style=\"vertical-align:top;\">'
|
||||||
|
result = header + result
|
||||||
|
|
||||||
|
for (char,code) in char_code:
|
||||||
|
result = result + '<tr><td style="font-size:x-large;' + \
|
||||||
|
'vertical-align:top;">' + \
|
||||||
|
char + '</td><td>'
|
||||||
|
|
||||||
|
for i in range(len(code)):
|
||||||
|
if (i < len(code) - 1):
|
||||||
|
result = result + code[i] + '<br/>'
|
||||||
|
else:
|
||||||
|
result = result + code[i] + '</td></tr>'
|
||||||
|
|
||||||
|
result = result + '</table>'
|
||||||
|
self.label_2.setText(result)
|
||||||
|
|
||||||
def input_characters(self):
|
def input_characters(self):
|
||||||
import re
|
import re
|
||||||
|
|
||||||
characters = self.lineEdit.text()
|
characters = self.lineEdit.text()
|
||||||
chinese_char_pattern = re.compile("^[\u4e00-\u9fa5]+$")
|
chinese_char_pattern = re.compile("^[\u2f00-\u2fd5\u4e00-\u9fcc\u3400-\u4db5\u20000-\u2a6d6\u2a700-\u2b734\u2b740-\u2b81d\u2b820-\u2cea1]+$")
|
||||||
is_chinese_chars = chinese_char_pattern.match(characters)
|
is_chinese_chars = chinese_char_pattern.match(characters)
|
||||||
|
|
||||||
if is_chinese_chars:
|
if is_chinese_chars:
|
||||||
char_code_list = [(ch,find_code(ch,self.c)) for ch in characters]
|
char_code_list = [(ch,find_code(ch,self.c)) for ch in characters]
|
||||||
print(char_code_list)
|
self.show_result(char_code_list)
|
||||||
else:
|
else:
|
||||||
print("error")
|
print("error")
|
||||||
|
|
||||||
|
|
18
ui.py
18
ui.py
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# Form implementation generated from reading ui file 'ui.ui'
|
# Form implementation generated from reading ui file 'ui.ui'
|
||||||
#
|
#
|
||||||
# Created: Wed Mar 23 23:22:07 2016
|
# Created: Fri Apr 1 23:13:43 2016
|
||||||
# by: PyQt4 UI code generator 4.10.4
|
# by: PyQt4 UI code generator 4.10.4
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
@ -76,7 +76,15 @@ class Ui_MainWindow(object):
|
||||||
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
|
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
|
||||||
self.horizontalLayout_2.addWidget(self.pushButton_2)
|
self.horizontalLayout_2.addWidget(self.pushButton_2)
|
||||||
self.verticalLayout.addLayout(self.horizontalLayout_2)
|
self.verticalLayout.addLayout(self.horizontalLayout_2)
|
||||||
self.label_2 = QtGui.QLabel(self.centralwidget)
|
self.scrollArea = QtGui.QScrollArea(self.centralwidget)
|
||||||
|
self.scrollArea.setWidgetResizable(True)
|
||||||
|
self.scrollArea.setObjectName(_fromUtf8("scrollArea"))
|
||||||
|
self.scrollAreaWidgetContents = QtGui.QWidget()
|
||||||
|
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 365, 219))
|
||||||
|
self.scrollAreaWidgetContents.setObjectName(_fromUtf8("scrollAreaWidgetContents"))
|
||||||
|
self.horizontalLayout_4 = QtGui.QHBoxLayout(self.scrollAreaWidgetContents)
|
||||||
|
self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4"))
|
||||||
|
self.label_2 = QtGui.QLabel(self.scrollAreaWidgetContents)
|
||||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
|
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
|
||||||
sizePolicy.setHorizontalStretch(0)
|
sizePolicy.setHorizontalStretch(0)
|
||||||
sizePolicy.setVerticalStretch(0)
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
@ -88,11 +96,13 @@ class Ui_MainWindow(object):
|
||||||
self.label_2.setIndent(5)
|
self.label_2.setIndent(5)
|
||||||
self.label_2.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByKeyboard|QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextBrowserInteraction|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse)
|
self.label_2.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByKeyboard|QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextBrowserInteraction|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse)
|
||||||
self.label_2.setObjectName(_fromUtf8("label_2"))
|
self.label_2.setObjectName(_fromUtf8("label_2"))
|
||||||
self.verticalLayout.addWidget(self.label_2)
|
self.horizontalLayout_4.addWidget(self.label_2)
|
||||||
|
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
|
||||||
|
self.verticalLayout.addWidget(self.scrollArea)
|
||||||
self.horizontalLayout_3.addLayout(self.verticalLayout)
|
self.horizontalLayout_3.addLayout(self.verticalLayout)
|
||||||
MainWindow.setCentralWidget(self.centralwidget)
|
MainWindow.setCentralWidget(self.centralwidget)
|
||||||
self.menubar = QtGui.QMenuBar(MainWindow)
|
self.menubar = QtGui.QMenuBar(MainWindow)
|
||||||
self.menubar.setGeometry(QtCore.QRect(0, 0, 387, 22))
|
self.menubar.setGeometry(QtCore.QRect(0, 0, 387, 23))
|
||||||
self.menubar.setObjectName(_fromUtf8("menubar"))
|
self.menubar.setObjectName(_fromUtf8("menubar"))
|
||||||
self.menu_Help = QtGui.QMenu(self.menubar)
|
self.menu_Help = QtGui.QMenu(self.menubar)
|
||||||
self.menu_Help.setObjectName(_fromUtf8("menu_Help"))
|
self.menu_Help.setObjectName(_fromUtf8("menu_Help"))
|
||||||
|
|
69
ui.ui
69
ui.ui
|
@ -97,15 +97,30 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
<property name="sizePolicy">
|
<property name="widgetResizable">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<bool>true</bool>
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||||
<string><html><head/><body><p>您查詢的行列碼為:
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>365</width>
|
||||||
|
<height>219</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string><html><head/><body><p>您查詢的行列碼為:
|
||||||
<table style="vertical-align:top;">
|
<table style="vertical-align:top;">
|
||||||
<tr>
|
<tr>
|
||||||
<td><span style=" font-size:18pt;">越</span></td>
|
<td><span style=" font-size:18pt;">越</span></td>
|
||||||
|
@ -117,22 +132,26 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</html></string>
|
</html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="textFormat">
|
<property name="textFormat">
|
||||||
<enum>Qt::AutoText</enum>
|
<enum>Qt::AutoText</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="indent">
|
<property name="indent">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="textInteractionFlags">
|
<property name="textInteractionFlags">
|
||||||
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||||
</property>
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -145,7 +164,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>387</width>
|
<width>387</width>
|
||||||
<height>22</height>
|
<height>23</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menu_Help">
|
<widget class="QMenu" name="menu_Help">
|
||||||
|
|
Loading…
Reference in a new issue