Python 001

# -*- coding: utf-8 -*-
# https://wiki.wxpython.org/Getting%20Started
import wx

# app = wx.App(False)   # 不要将stdout/stderr重定向到窗口 don't redirect stdout/stderr to a window.
# frame = wx.Frame(None, wx.ID_ANY, "Hello World")  # 一个顶级窗口框架 A Frame is a top-level window.
# 分别为父对象,wx.ID_ANY(让wx分配一个ID,常见用法),标题
# frame.Show(True)  # 显示这个框架,使窗口可见
# app.MainLoop()    # 启动应用程序的主循环

# class MyFrame(wx.Frame):
#     def __init__(self, parent, title):
#         wx.Frame.__init__(self, parent, title = title, size = (200, 200))
#         self.control = wx.TextCtrl(self, style = wx.TE_MULTILINE)
#         # 使用wx.TextCtrl小部件,并调整参数为多行文本
#         self.Show(True)

# app = wx.App(False)
# frame = MyFrame(None, 'Small editor')
# app.MainLoop()

# class MainWindow(wx.Frame):
#     def __init__(self, parent, title):
#         wx.Frame.__init__(self, parent, title = title, size = (200, 100))
#         self.control = wx.TextCtrl(self, style = wx.TE_MULTILINE)
#         self.CreateStatusBar() # 状态栏

#         filemenu = wx.Menu() # 菜单
#         filemenu.Append(wx.ID_ABORT, "&About", "Information about this program")
#         filemenu.AppendSeparator()
#         filemenu.Append(wx.ID_EXIT, "E&xit", " Terminate the program")

#         menuBar = wx.MenuBar() # 菜单栏
#         menuBar.Append(filemenu, "&File") # 将菜单放入菜单栏

#         self.SetMenuBar(menuBar) # 使菜单栏被显示在框架
#         self.Show(True)

# app = wx.App(False)
# frame = MainWindow(None, "Sample editor")
# app.MainLoop()

import os
import wx

class MainWindow(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title = title, size = (200, 100))
        self.control = wx.TextCtrl(self, style = wx.TE_MULTILINE)
        self.CreateStatusBar()

        filemenu = wx.Menu()
        menuAbout = filemenu.Append(wx.ID_ABORT, "&About", "Information about this program")
        menuExit = filemenu.Append(wx.ID_EXIT, "E&xit", " Terminate the program")

        menuBar = wx.MenuBar()
        menuBar.Append(filemenu, "&File")
        self.SetMenuBar(menuBar)

        self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout)
        self.Bind(wx.EVT_MENU, self.OnExit, menuExit)
        # Bind方法,将对象绑定到事件,即点击后,self.OnAbout被执行
        # EVT_MENU为选择菜单项事件

        self.Show(True)

    def OnAbout(self, e):
        dlg = wx.MessageDialog(self, "A small text editor", "About Sample Editor", wx.OK)
        dlg.ShowModal()
        dlg.Destroy()
    # 点击About后弹出信息,注意最后的按键为wx.OK
    # 此为wx的子类的实例

    def OnExit(self, e):
        self.Close(True)
    # 点击Exit后关闭程序

app = wx.App(False)
frame = MainWindow(None, "Sample editor")
app.MainLoop()
import sqlite3
path = r"C:\Users\Qiao\Documents\SQL\本底调查.db"
db = sqlite3.connect(path).cursor()

# 获取数据库表名
db.execute("SELECT name FROM sqlite_master WHERE type = 'table'")
table_name = [x[0] for x in db.fetchall()]
print(table_name)
# db.close()

# 获取数据库表字段名
col_names = []
for i in table_name:
    db.execute('PRAGMA table_info({})'.format(i))
    col_name = tuple([x[1] for x in db.fetchall()])
    col_names.append(col_name)

print(col_names[0])