前提・実現したいこと
SQLiteのDBの中に
Test_1_table
aita0,atai1,atai2,atai3
"ああ","いい","うう","ええ"
"aa","ii","uu","ee"
"aaa","iii","uuu","eee"
"あああ","いいい","ううう","えええ"
が入っており。
それらをすべてWXPythonのGUIで表示したいです。
Python初心者ですが、よろしくお願いいたします。
発生している問題・エラーメッセージ
GUI上で ああ,いい,うう,ええ aa,ii,uu,ee aaa,iii,uuu,eee あああ,いいい,ううう,えええ と表示してほしいのですが実際に動かしてみると C:\Users\xxx\Desktop>python test03.py ああ,いい,うう,ええ となり1行目までしか表示されません
該当のソースコード
Python3.6
1import wx 2import sqlite3 3class App(wx.Frame): 4 """ GUI """ 5 def __init__(self, parent, id, title): 6 wx.Frame.__init__(self, parent, id, title, size=(500, 500), style=wx.DEFAULT_FRAME_STYLE) 7 # パネル 8 panel_1 = wx.Panel(self, wx.ID_ANY) 9 10 text_1 = wx.TextCtrl(panel_1, wx.ID_ANY, 'ああ') 11 12 text_2 = wx.TextCtrl(panel_1, wx.ID_ANY, 'いい') 13 14 text_3 = wx.TextCtrl(panel_1, wx.ID_ANY, 'うう') 15 16 text_4 = wx.TextCtrl(panel_1, wx.ID_ANY, 'ええ') 17 18 def click_button_1(event): 19 dbname = 'database.db' 20 conn = sqlite3.connect(dbname) 21 c = conn.cursor() 22 c.execute("create table Test_1_table(atai0,atai1,atai2,atai3);") 23 text_1_1 = (text_1.GetValue()) 24 text_2_1 = (text_2.GetValue()) 25 text_3_1 = (text_3.GetValue()) 26 text_4_1 = (text_4.GetValue()) 27 28 purchases = (text_1_1,text_2_1,text_3_1,text_4_1) 29 sql = 'insert into Test_1_table values(?,?,?,?);' 30 c.execute(sql , purchases) 31 c.execute("select atai0,atai1,atai2,atai3 from Test_1_table;") 32 conn.commit() 33 conn.close() 34 35 layout_1.Add(text_1, flag=wx.EXPAND | wx.ALL,border=10) 36 layout_1.Add(text_2, flag=wx.EXPAND | wx.ALL,border=10) 37 layout_1.Add(text_3, flag=wx.EXPAND | wx.ALL,border=10) 38 layout_1.Add(text_4, flag=wx.EXPAND | wx.ALL,border=10) 39 layout_1.Add(button_1, 0, wx.GROW) 40 41 button_1 = wx.Button(panel_1, wx.ID_ANY, '送信') 42 button_1.Bind(wx.EVT_BUTTON,click_button_1) 43 44 panel_1.SetSizer(layout_1) 45 46class App_1(wx.Frame):#資料台帳閲覧 47 48 def __init__(self, parent, id, title): 49 wx.Frame.__init__(self, parent, id, title, size=(700, 700), style=wx.DEFAULT_FRAME_STYLE) 50 51 panel_2 = wx.Panel(self, wx.ID_ANY) 52 53 dbname = 'database.db' 54 55 conn = sqlite3.connect(dbname) 56 c = conn.cursor() 57 c.execute("select atai0,atai1,atai2,atai3 from Test_1_table;") 58 row = c.fetchone() 59 while (row != None): 60 maped_list = map(str, row) #mapで要素すべてを文字列に 61 mojiretu = ''.join(maped_list) 62 read_text_1 = wx.StaticText(panel_5, wx.ID_ANY, mojiretu) 63 row = c.fetchone() 64 65 layout_1 = wx.BoxSizer(wx.VERTICAL) 66 layout_1.Add(read_text_1) 67 68 panel_2.SetSizer(layout_1) 69 70app = wx.App() 71app_1 = wx.App() 72App(None, -1, 'test') 73App_1(None, -1, 'test_2') 74app.MainLoop() 75app_1.MainLoop()
補足情報(FW/ツールのバージョンなど)
Python3.6
Python
SQLite
Python 2.7
Python 3.x
SQL
あなたの回答
tips
プレビュー