我正在TKinterUbuntu上编写一个Python程序来导入和打印Textwidget中特定文件夹中的文件名.它只是将文件名添加到Text
窗口小部件中的先前电影名称,但我想首先清除它,然后添加一个新的文件名列表.但我正在努力清除Text小部件以前的文件名列表.
有人可以解释如何清除Text小部件吗?
屏幕截图和编码如下:
import os
from Tkinter import *
def viewFile():
path = os.path.expanduser("~/python")
for f in os.listdir(path):
tex.insert(END, f + "\n")
if __name__ == '__main__':
root = Tk()
step= root.attributes('-fullscreen', True)
step = LabelFrame(root, text="FILE MANAGER", font="Arial 20 bold italic")
step.grid(row=0, columnspan=7, sticky='W', padx=100, pady=5, ipadx=130, ipady=25)
Button(step, text="File View", font="Arial 8 bold italic", activebackground=
"turquoise", width=30, height=5, command=viewFile).grid(row=1, column=2)
Button(step, text="Quit", font="Arial 8 bold italic", activebackground=
"turquoise", width=20, …Run Code Online (Sandbox Code Playgroud) 我正在RaspberryPi(Raspbian)上用Python编写程序,以将音频文件与视频文件合并/合并。
音频文件的格式为WAVE VIdeo文件的格式为h264
音频和视频已经成功同时录制和创建,我现在只需要合并它们即可。
您能指导我该怎么做吗?
我为RaspberryPi购买了一个USB音频控制器,以便捕获音频输入.我已经在Rasbian上完成了以下步骤,但仍然不确定音频捕获.你能指导我如何得到它吗?
键入以下命令以安装音频设备
pi@raspberrypi ~ $ sudo apt-get install alsa-utils
Run Code Online (Sandbox Code Playgroud)
成功检测
pi@raspberrypi ~ $ lsusb
pi@raspberrypi ~ $ amixer
pi@raspberrypi ~ $ alsamixer
Run Code Online (Sandbox Code Playgroud)
同时配置USB音频设备以使其成为默认设备
/etc/modprobe.d/alsa-base.conf
Run Code Online (Sandbox Code Playgroud)
通过添加磅/哈希符号
options snd-usb-audio index=2
#options snd-usb-audio index=2
Run Code Online (Sandbox Code Playgroud) 我在RaspberryPi上用Python编写程序,但是我收到了一个错误
ImportError No module named pyaudio
Run Code Online (Sandbox Code Playgroud)
之后我尝试了
git clone http://people.csail.mit.edu/hubert/git/pyaudio.git
Run Code Online (Sandbox Code Playgroud)
但又得到了另一个
fatal: destination path 'pyaudio' already exists and is not an empty directory.
Run Code Online (Sandbox Code Playgroud)
能否指导我如何在RaspberryPi中安装PyAudio
我收到了错误
No module named cv2
Run Code Online (Sandbox Code Playgroud)
你能指导我应该输入什么命令来安装CV2(sudo qpt-get install ..?)谢谢
import numpy as np
import cv2
cap = cv2.VideoCapture('vtest.avi')
while(cap.isOpened()):
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud) 我正在尝试计算我的文件夹(/ Home/python)中的文件数量,因此我制作了一个简短的程序
import os.path
path = '/Home/python'
num_files = len([f for f in os.listdir(path)if os.path.isfile(os.path.join(path, f))])
Run Code Online (Sandbox Code Playgroud)
但它给了我一个这样的错误
Traceback (most recent call last):
File "count_number_of_files_folder.py", line 3, in <module>
num_files = len([f for f in os.listdir(path)if os.path.isfile(os.path.join(path, f))])
OSError: [Errno 2] No such file or directory: '/Home/python'
Run Code Online (Sandbox Code Playgroud)
你可以帮助我帮助我制作无bug程序.谢谢

我正在ubuntu上用python编写程序,但是由于几天的时间,我遇到了这个非常恼人的问题,
Traceback (most recent call last):
File "/home/tansen/Documents/python2/button25_01JanV1.py", line 1, in <module>
import Tkinter,ttk
File "/home/tansen/Documents/python2/Tkinter.py", line 1, in <module>
from Tkinter import Tk, Label, Button
ImportError: cannot import name 'Tk'
Run Code Online (Sandbox Code Playgroud)
在此程序运行正常之前,我成功运行了多个时间程序
import tkinter.ttk
from tkinter import *
def viewFile():
pass
if __name__ == '__main__':
root = Tk()
step = LabelFrame(root,text="FILE MANAGER", font = "Arial 20 bold italic")
step.grid(row=1, columnspan=7, sticky='W',padx=100, pady=5, ipadx=130, ipady=25)
Button(step, text="OpenFile", font = "Arial 8 bold italic", activebackground="turquoise", width=30, height=5, command=viewFile).grid (row= 6, column =3) …Run Code Online (Sandbox Code Playgroud) python ×6
raspberry-pi ×3
tkinter ×2
audio ×1
count ×1
directory ×1
ffmpeg ×1
file ×1
importerror ×1
numbers ×1
pyaudio ×1
python-3.x ×1
raspbian ×1
text-widget ×1
tk-toolkit ×1
ubuntu ×1
video ×1