私は提案のためにloockingしています:私はすべてのGUIコードを書くmain.pyと呼ばれるモジュールを持っています。すべてのsqlite querysを繰り返すのを避けるために、 .py。 main.py:B = tk.Entry() B1 = B.get() 私はメソッドvalidate.Thatを持っているので、Bの変数を取ってquery.Somethingのようにします。 //funciónがB1.get()の値が// 存在するかどうかをdbに問い合わせます。clclass myclass() def validate(a): .... SELECT FROM table WHERE col_val =(a) そして、ここで私はB1の価値をどのようにして検証メソッドに渡すか知っていません。何か提案がありがとうございます。私の悪い英語のために申し訳ありません。 s = myclass() s.validate(B1)のようなものでしょうか?integrate tkinter whit Sqlite3
-2
A
答えて
0
私はやったことがありますが、私はより良いことができると思います。私のやり方はここにあります。申し訳ありませんが、私はコンピュータにいませんでした。モジュールmain.py
import tkinter as tk
import ingreso
from tkinter import messagebox
from ingreso import myclass
import sqlite3
def __init__(self):
tk.Tk.__init__(self)
frame = tk.Frame(self,width=380, height=420, bg="white", colormap="new")
self.fi = tk.Entry(frame)
self.fi.pack()
self.dni = tk.Entry(frame)
self.dni.pack()
frame.pack()
self.hi = tk.Button(self,text="guardar", command= self.validate)
self.hi.pack()
def validate(self):
messagebox.showwarning(title="validador",message="Se procedera a validar los campos")
fi= self.fi.get() #That is that i pass as class argument
dni= self.dni.get()
if len(fi)== 0 or len(dni)==0:
tk.messagebox.showwarning(message="campos requeridos")
else:
query = myclass(fi, dni) #Create the objet at instance of class
val = query.validar() #Determine if the object exist or not
があり
モジュールingreso.pyがあります:
class myclass():
def __init__(self, a= " ", b= " "): #There is the attributes of the class
self.db = db
self.a = a
self.b = b
def validar(self): # here i determine if the objet exist or not
fi = self.a
dni = self.b
conn = sqlite3.connect('ecina.db')
c = conn.cursor()
c.execute('''SELECT COUNT(*) FROM admision WHERE fi = (?) AND dni =(?)''', (fi, dni))
r = c.fetchone()
number_of_rows=r[0]
return number_of_rows
それは作品ですが、任意の提案や修正が非常にappreciate.Thanksたくさんになります。
関連する問題
- 1. Python3、Tkinter、SQLite3 - ログインコーディングエラー
- 2. jquery bxslider integrate ajax
- 3. TkinterからSqlite3へのデータの挿入 - sqlite3.OperationalError:near ")":構文エラー
- 4. Jackrabbit Oak and integrate Solr
- 5. Integrate - Googleのホテルファインダー - ウェブアプリケーション
- 6. チャットlaravel 5とnotificaciones whit Whatsapp
- 7. tkinterエントリからsqlite3テーブルへの名前の比較
- 8. データベース全体のデータを表示するtkinter sqlite3
- 9. tkinterを使用してsqlite3データベースからテキストを出力する
- 10. ログイン後のPython、Tkinter、SQlite3新しいウィンドウにユーザをリダイレクト
- 11. テキストファイル、whit space pronlemを分割する
- 12. 動的表を作成するwhit innerHTML
- 13. ウィンドウ内でのバーコード生成でのwhit save()の問題
- 14. 別の範囲のIPアドレスのwhitドッカーコンテナを復元
- 15. VB.NetでCirce Whit GMapを作成する方法
- 16. PostgreSQLの使い方json_array_elements whit WHERE <value> IN節
- 17. 画像ファイルをajax whit django経由でアップロードします
- 18. Rxphoto:どのように.requestUri(context、TypeRequest.GALLERY)whit RxJava?
- 19. チャットルームwhit GIFと絵文字と画像Java
- 20. は動作しませんcodeigniter whit amazon ec2
- 21. SQLite3クエリエラー
- 22. sqlite3 NSDictionaryメモリリーク
- 23. sqlite3のPython datetimes
- 24. C++ sqlite3バインドパラメータ
- 25. SQLite3とマルチプロセッシング
- 26. sqlite3の - コールバック
- 27. SQLite3とSystem.currentTimeMillis()
- 28. パイソンsqlite3.OperationalError
- 29. Pythonの、sqlite3の:
- 30. Sqlite3 network oddity
あなたがしようとしていることを複製するために使用できる[mcve]を作成してください。 –