add ui
This commit is contained in:
parent
13882ac1a0
commit
8efa6bea4a
2 changed files with 146 additions and 5 deletions
22
__main__.py
Normal file → Executable file
22
__main__.py
Normal file → Executable file
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
#-*-coding:utf-8-*-
|
||||
import sqlite3
|
||||
import tkinter as tk
|
||||
|
||||
def table2list(table_tsv):
|
||||
with open(table_tsv,'r',encoding='utf-16') as tsv:
|
||||
|
@ -45,25 +46,36 @@ def import_all_table():
|
|||
list2sqlite(list,c)
|
||||
|
||||
db.commit()
|
||||
return db, c
|
||||
|
||||
def find_code(char,c):
|
||||
|
||||
raw_code = c.execute('''SELECT code FROM ime WHERE char = ?''', (c,))
|
||||
raw_query = c.execute('''SELECT code FROM ime WHERE char = ?''', (char,))
|
||||
raw_code = [i[0] for i in raw_query.fetchall()]
|
||||
code = [rawcode2truecode(i) for i in raw_code]
|
||||
code = sorted(code,reverse=True)
|
||||
print(code)
|
||||
return code, c
|
||||
|
||||
|
||||
def rawcode2truecode(raw):
|
||||
#1^ = Q, 1- = A, 1v = Z, 2^ = W, 2- = S ......, 0^ = P, 0- = :, 0v = ?
|
||||
raw_code_order = "QAZWSXEDCRFVTGBYHNUJMIK<OL>P:?"
|
||||
true_code = ""
|
||||
|
||||
for i in raw:
|
||||
i_index = raw_code_order.index(i)
|
||||
column = str(i_index // 3)
|
||||
raw_number = index % 3
|
||||
raw = ['^','-','v'][raw_number]
|
||||
uncorrected_column = i_index // 3
|
||||
#correct the column no. 2 -> 3; 9 -> 0
|
||||
column = str(uncorrected_column + 1)[-1]
|
||||
raw_number = i_index % 3
|
||||
raw = ['^','-','v'][raw_number] # 0=^;1=-;2=v
|
||||
column_and_raw = column + raw
|
||||
true_code = true_code + column_and_raw
|
||||
|
||||
return true_code
|
||||
|
||||
import_all_table()
|
||||
|
||||
db,c = import_all_table()
|
||||
|
||||
find_code("越",c)
|
||||
|
|
129
ui.ui
Normal file
129
ui.ui
Normal file
|
@ -0,0 +1,129 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>478</width>
|
||||
<height>408</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>findarray30code - 行列30查碼</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>20</y>
|
||||
<width>301</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>66</width>
|
||||
<height>15</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>輸入文字</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>400</x>
|
||||
<y>20</y>
|
||||
<width>61</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>查詢</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>400</x>
|
||||
<y>60</y>
|
||||
<width>61</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>清空</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>110</y>
|
||||
<width>421</width>
|
||||
<height>211</height>
|
||||
</rect>
|
||||
</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>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::AutoText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>-2</number>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>478</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_Help">
|
||||
<property name="title">
|
||||
<string>&Help</string>
|
||||
</property>
|
||||
<addaction name="action_About"/>
|
||||
</widget>
|
||||
<addaction name="menu_Help"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="action_About">
|
||||
<property name="text">
|
||||
<string>&About...</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in a new issue