Python】GUI界面简单呈现

1、Tkinter界面GUI

2、EasyGUI

# -*- coding: utf-8 -*-
# 本程序主要用于文本数据打标签
from easygui import *
import sys
# reload(sys)
# sys.setdefaultencoding("utf-8")

# 文件夹名,此处打码,需要个人修改
folder = r'##############'   
# 标题,需要个人修改
title = "这是GUI的标题"
# 读入文件,此处打码,需要个人修改,建议txt文件
label_read = r'##############'
# 写出文件,此处打码,需要个人修改,建议txt文件
label_write = r'##############'

while 1:
    with open(folder + label_read, 'r', encoding="utf-8") as read_file:
        lines = read_file.readlines()

    # 读取上次标注,因此可以在标注时随时中断
    with open(folder + label_write, 'r',encoding="utf-8") as write_file:
        position = len(write_file.readlines())
        
    # 标注用的选项,单选,需要个人修改
    boxes = ["label1", "label2", "label3"]
    
    count = 0  # 计数
    for line in lines:
        count += 1
        
        line = line.strip()   # 去 \n
        text=line.split("\t")[2]   # 文本所在的列号不同,需要个人修改
        msg="".join([st for st in text if ord(st) in range(65536)])   # 去表情符
        
        print(count,msg)   # 打印位置,显得标注有存在感
        
        if count <= position or line.split("\t")[-2] == "0":  # 一些跳过的条件,要么特判,要么已经标注过
        	continue

        # 创建GUI,返回点击内容,msg为显示的文本,title为GUI的标题,boxes为选项
       	choice1=choicebox(msg, title, boxes)   -
                
        with open(folder + label_write, 'a',encoding="utf-8") as write_file:
        	content = line + "\t" + choice1   # 输出内容
            write_file.write(content+'\n')
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐