小编fra*_*kot的帖子

没有边框的Tkinter标签图片

这是我的第一篇文章.我经常访问堆栈溢出,我以前总是找到所有问题的答案,但今天不是.

我尝试在窗口中将图像显示为标签,但这并不是我认为Tkinter会如何显示它们.换一种说法.我有几个小图像,它们应该彼此相邻,没有任何间隙.但除了我所有的努力之外,Tkinter总是在两个相邻元素之间放置小边框或间隙(可能是1-2像素).

from tkinter import *
from tkinter import ttk

class MainWindow():

def __init__(self, mainWidget):

    self.status_bar_text = StringVar()
    self.status_bar_text.set('')

    self.image_to_place = PhotoImage(file='my_image.png')

    self.main_frame = ttk.Frame(mainWidget, width=768, height=480, padding=(0, 0, 0, 0))
    self.main_frame.place(x=0, y=0)

    self.status_bar = ttk.Label(mainWidget, width=768, border=1, anchor=W, relief=SUNKEN, textvariable=self.status_bar_text)
    self.status_bar.place(x=0, y=480)

    self.main_gui()

def main_gui(self):
    i = 0
    plate_cords = [[0, 0], [24, 0], [48, 0], [72, 0], [96, 0], [120, 0]]

    for plate in plate_cords:
        self.wall_label = ttk.Label(self.main_frame, image=self.image_to_place)
        self.wall_label.place(x=plate_cords[i][0], y=plate_cords[i][1])
        i += 1
    del i


def main(): …
Run Code Online (Sandbox Code Playgroud)

python tkinter labels

3
推荐指数
1
解决办法
5145
查看次数

Python请求模块导入错误

我已经安装了python请求模块.我使用标准pip install requests,安装成功但它根本不起作用.我无法将此模块导入任何脚本文件.我总是得到一个错误.

Traceback (most recent call last):
  File "D:\Rzeczy Mariusza\Python\aaaa.py", line 3, in <module>
    import requests
  File "D:\Programy\Python34\lib\site-packages\requests\__init__.py", line 58, in <module>
    from . import utils
  File "D:\Programy\Python34\lib\site-packages\requests\utils.py", line 12, in <module>
    import cgi
  File "D:\Programy\Python34\lib\cgi.py", line 39, in <module>
    from email.parser import FeedParser
  File "D:\Programy\Python34\lib\email\parser.py", line 12, in <module>
    from email.feedparser import FeedParser, BytesFeedParser
  File "D:\Programy\Python34\lib\email\feedparser.py", line 27, in <module>
    from email import message
  File "D:\Programy\Python34\lib\email\message.py", line 16, in <module>
    from email import utils
  File "D:\Programy\Python34\lib\email\utils.py", …
Run Code Online (Sandbox Code Playgroud)

python python-requests

2
推荐指数
1
解决办法
3245
查看次数

标签 统计

python ×2

labels ×1

python-requests ×1

tkinter ×1