tk

【Python 问题】ModuleNotFoundError: No module named 'tkinter'

江枫思渺然 提交于 2020-03-03 15:43:52
运行 Python 文件遇到问题 ModuleNotFoundError: No module named 'tkinter' 时,不需要使用 pip 安装 tkinter 包,而是使用 sudo apt-get install tcl-dev tk-dev python3-tk 指令来完成安装。 来源: CSDN 作者: HuanCaoO 链接: https://blog.csdn.net/HuanCaoO/article/details/104629869

Word2vec

╄→гoц情女王★ 提交于 2020-02-23 18:38:08
在之前的学习中提到过one-hot向量表示方式,虽然它们构造起来很容易,但通常并不是一个好选择。一个主要的原因是,one-hot 词向量无法准确表达不同词之间的相似度,如我们常常使用的余弦相似度。 例如 beautiful和lovely是两个表示含义相近的词,他们应该在向量空间上有一定的相似度,而相对的,ugly这样的词距离他们就应该很远,Word2Vec 词嵌入工具的提出正是为了解决上面这个问题,它将每个词表示成一个定长的向量,并通过在语料库上的预训练使得这些向量能较好地表达不同词之间的相似和类比关系,以引入一定的语义信息。基于两种概率模型的假设,我们可以定义两种 Word2Vec 模型 Skip-Gram 跳字模型 假设背景词由中心词生成,即建模 P(wo∣wc),其中 wc 为中心词,wo 为任一背景词; CBOW (continuous bag-of-words) 连续词袋模型 假设中心词由背景词生成,即建模 P(wc∣Wo),其中 Wo 为背景词的集合。 在这里我们主要介绍 Skip-Gram 模型的实现,CBOW 实现与其类似,读者可之后自己尝试实现。后续的内容将大致从以下四个部分展开: PTB 数据集 Skip-Gram 跳字模型 负采样近似 训练模型 PTB数据集 为了训练 Word2Vec 模型,我们就需要一个自然语言语料库,模型将从中学习各个单词间的关系

Python之Tkinter模块学习

扶醉桌前 提交于 2020-02-13 22:29:19
本文转载自:http://www.cnblogs.com/kaituorensheng/p/3287652.html Tkinter 模块("Tk 接口")是Python的标准Tk GUI工具包的接口 作为实践, 用Tkinter做了个 ascii码转化查询表 ,本文从四点介绍 产品介绍 设计规划 相关知识 源码附件 1. 产品介绍 界面    功能 通过 输入 字符或数字查询对应的信息 通过 选择 列表中的信息查询对应的信息 2. 设计规划 规划图 3. 相关知识 首先看怎么产生第一个窗口 from Tkinter import * #引用Tk模块 root = Tk() #初始化Tk() root.mainloop() #进入消息循环 几个常用属性 title: 设置窗口标题 geometry: 设置窗口大小 resizable():设置窗口是否可以变化长 宽 # -*- coding: cp936 -*- from Tkinter import * root = Tk() root.title("hello world") root.geometry('200x100') #是x 不是* root.resizable(width=False, height=True) #宽不可变, 高可变,默认为True root.mainloop() 介绍以下几个控件的用法 Label

Python Tkinter 简单使用

我与影子孤独终老i 提交于 2020-02-13 09:06:52
简单的一些实例,能够实现一般的功能就够用了 Tkinter: 创建顶层窗口: # -*- coding: utf-8 -*- from Tkinter import * root = Tk() root.title("顶层窗口") root.mainloop() Label使用: # -*- coding: utf-8 -*- from Tkinter import * root = Tk() root.title("顶层窗口") label = Label(root, text="Hello World!") label.pack() root.mainloop() 加入一些参数: # -*- coding: utf-8 -*- from Tkinter import * root = Tk() root.title("顶层窗口") label = Label(root, text="Hello World!", height=10, width=30, fg="black", bg="pink") label.pack() root.mainloop() Frame: # -*- coding: utf-8 -*- from Tkinter import * root = Tk() root.title("顶层窗口") for relief in [RAISED, SUNKEN

源代码查看工具 Source Navigator 使用心得

安稳与你 提交于 2020-02-13 05:30:35
在ubuntu 10.04下试用了Source Navigator,有条件还是装Source insight吧,不是一个级别的,非常不方便。 Source Navigator 是Red Hat出品的一款查看源代码的工具,非常好用,与Windows下的Source Insight有一敌。但是它的界面不怎么好看,用的不是GTK图形库,所以界面风格与Gnome不一致,操作上也有些不同。除了这些,其它功能都非常强大,细数如下。里面的一些简写约定如下: Code Area cl Classes con Constants e Enums ec Enum Values fd Function Declarations fr friends fu Functions gv Global Variables iv Instance Variables ma Macros md Method Definitions mi Method Implementations t Typedefs un Unions lv Local variables ud Undefined Cross-Reference r Read w Written p Passed u Unused SNav的代码窗口有6个标签页,它们分别是 “Edit” “Hierarchy” “Class” “Xref”

TK mybatis SelectByPrimaryKey异常

送分小仙女□ 提交于 2020-02-12 18:09:01
今天在使用TK mybatis 插件时出现了一个奇怪的现象,当我调用selectByPrimaryKey(7)时,mybatis的sql日志打印为如下所示 ===> Preparing SELECT id,a, b, c FROM test WEHER id =? and a = ? and b = ? and c=? ===> Parameters: 7(Long),7(Long),7(Long),7(Long),7(Long) 然后我百度查了相似问题, 发现是PO类里没有给主键添加javax.persistence.@ID注解导致的 添加完后的sql打印为: ===> Preparing SELECT id,a, b, c FROM test WEHER id =? ===> Parameters: 7(Long) 来源: https://www.cnblogs.com/myblogs-miller/p/12299958.html

tk(三)按钮的事件绑定

拜拜、爱过 提交于 2020-02-04 23:39:36
(三)按钮的事件绑定 ==1.普通的Button绑定事件== (1)说明: Button 使用 command=功能函数 来绑定 Button(win, text="确定", command=功能函数) ==案例六== (1)源代码: 我们创建一个简单的窗体,只有一个按钮控件, 我们绑定的事件是,当我们点击"确定"按钮时,会输出“你点击了按钮” import tkinter as tk win = tk.Tk() # 定义功能函数, event是必须添加的参数,不知道来自哪里 def button_command(): print("你点击了按钮") # 绑定事件 btn = tk.Button(win, text="确定", command=button_command) btn.place(relx=0.2, rely=0.2, relwidth=0.5, relheight=0.1) win.geometry("300x300+200+200") win.mainloop() (2)输出效果: ==2.传参数Button绑定事件== (1)说明: 我们使用Button传递数值时,需要用: lambda: 功能函数(var1, var2, ……) ==案例七== (1)源代码: 我们同样创建一个简单的窗体,只有一个控件按钮 我们绑定的事件是,当我们点击按钮时,会传入两个参数

【tcltk - tk】 proc gridLite

梦想的初衷 提交于 2020-02-01 22:33:46
参数说明: w -- pathName in -- grid 的 -in,取值 - 表示不配置 r, c -- grid 的 -row 和 -column s -- grid 的 -sticky,取值 - 表示,不配置,取值 x 表示 nsew rs, cs -- grid 的 -rowspan 和 -columnspan rw, cw -- grid 的 columnconfigure index -weight 和 rowconfigure index -weight,取值表示 inde 时表示 -weight yes,取值 - 表示不配置 proc gridLite {w in r c {s -} {rs 1} {cs 1} {rw -} {cw -}} { if {$in eq {-}} {winfo parent $w} switch -- $s - {set s {} } x {set s {-sticky nsew} } default {set s "-sticky $s"} grid $w -in $in -column $c -row $r {*}$s -columnspan $cs -rowspan $rs if {[string is digit -strict $rw]} {grid rowcon $in $rw -weight 1} if {

Using Matplotlib with TKAgg or Qt5Agg backend on 4K screen

杀马特。学长 韩版系。学妹 提交于 2020-02-01 04:37:05
问题 I'm using Matplotlib 2.0 with Python 3.6 on Ubuntu 16.04 to create plots of data. The computer monitor is 4k resolution at 3840x2160. Plot figures appear really small with tiny font: I have tried the TKAgg and Qt5Agg backends for Matplotlib but the figure window still appears small on my 4K display. Can the backend be configured to scale the figure windows for better viewing on high resolution displays? 回答1: You can tell matplotlib to create a high dpi figure using plt.figure(dpi=300) before