diff --git a/__main__.py b/__main__.py old mode 100644 new mode 100755 index 59df166..82f0188 --- a/__main__.py +++ b/__main__.py @@ -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
    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) diff --git a/ui.ui b/ui.ui new file mode 100644 index 0000000..0587858 --- /dev/null +++ b/ui.ui @@ -0,0 +1,129 @@ + + + MainWindow + + + + 0 + 0 + 478 + 408 + + + + findarray30code - 行列30查碼 + + + + + + 90 + 20 + 301 + 21 + + + + + + + 10 + 20 + 66 + 15 + + + + 輸入文字 + + + + + + 400 + 20 + 61 + 26 + + + + 查詢 + + + + + + 400 + 60 + 61 + 26 + + + + 清空 + + + + + + 30 + 110 + 421 + 211 + + + + <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> + + + Qt::AutoText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + -2 + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + 0 + 0 + 478 + 21 + + + + + &Help + + + + + + + + + &About... + + + + + +