当前位置: 首页 > news >正文

进制转换结合tk可视化窗口

import tkinter as tk
from tkinter import ttk
import tkinter.messagebox
root=tk.Tk()
root.geometry('800x600+350+100')
root.title('进制转换小工具')input_text=tk.Text(root,height=2,width=16)
input_text.place(x=250,y=1)
output_text=tk.Text(root,height=2,width=16)
output_text.place(x=400,y=1)
combo=ttk.Combobox(root,values=['10->2','2->10','10->8','8->10','10->16','16->10',])
combo.place(x=300,y=40)
combo.set('10->2')
his_text = tk.Text(root,height=4,width=44)
his_text.place(x=225,y=110)
def click_int_to_bin():get_input_text = input_text.get('1.0','end')if get_input_text.strip() == '' or get_input_text.strip() == ' ' or get_input_text.strip() is None:tkinter.messagebox.showinfo('提示','未输入需要转换的初始值')return 0get_combo=combo.get()output_text.delete('1.0','end')if get_combo=='10->2':a = bin(int(get_input_text))elif get_combo=='2->10':a = int(get_input_text, 2)elif get_combo=='8->10':a = int(get_input_text, 8)elif get_combo=='10->8':a = oct(int(get_input_text))elif get_combo=='16->10':a = int(get_input_text, 16)elif get_combo=='10->16':a = hex(int(get_input_text))else:tkinter.messagebox.showinfo('提示', '你选择的编码形式错误或者字符类型错误')output_text.insert('1.0',a)history=get_combo,':',get_input_text.strip(),'-->',ahis_text.delete('1.0', 'end')his_text.insert('1.0',history)button1=tk.Button(root,font=('Arial',10),text='转换进制',command=click_int_to_bin)
button1.place(x=225,y=70)root.mainloop()
http://www.lryc.cn/news/587267.html

相关文章:

  • C++高频知识点(十三)
  • Wireshark的安装和基本使用
  • 理解 Robots 协议:爬虫该遵守的“游戏规则”
  • Dubbo + Spring Boot + Zookeeper 快速搭建分布式服务
  • TDengine 使用最佳实践(2)
  • 《Llama: The Llama 3 Herd of Models》预训练数据篇——论文精读笔记
  • html-input 系列
  • ConcurrentHashMap笔记
  • ROS2中的QoS(Quality of Service)详解
  • 【基础算法】倍增
  • 从“被动巡检”到“主动预警”:塔能物联运维平台重构路灯管理模式
  • 动态规划题解_将一个数字表示成幂的和的方案数【LeetCode】
  • 《夏重庆》——一场暴雨的立体诗篇(DeepSeek赏析)
  • SQL140 未完成率top50%用户近三个月答卷情况
  • Flask中的路由尾随斜杠(/)
  • Kafka——Kafka 线上集群部署方案怎么做?
  • 代理模式:控制对象访问
  • AutoLabor-ROS-Python 学习记录——第二章 ROS通信机制
  • CATIA许可价格高,设计部门如何精细化分配?
  • Python 数据挖掘之数据探索
  • 鸿蒙选择本地视频文件,并获取首帧预览图
  • 【算法】贪心算法:柠檬水找零C++
  • 密码学系列文(1)--密码学基础概念详解
  • 密码学系列文(2)--流密码
  • ansible自动化部署考试系统前后端分离项目
  • 在 C# 中调用 Python 脚本:实现跨语言功能集成
  • MySQL逻辑删除与唯一索引冲突解决
  • C++高频知识点(九)
  • 39.Sentinel微服务流量控制组件
  • 【一起来学AI大模型】部署优化推理加速:vLLM