Форум сайта python.su
from ctypes import * DLL = cdll.LoadLibrary('D103') print(DLL) DLL.dgauss_.argtypes = [POINTER(c_wchar_p),POINTER(c_int),POINTER(c_double), POINTER(c_double), POINTER(c_double)] DLL.dgauss_.restype = c_double DOBType = c_double input1 = DOBType(1.0) input2 = DOBType(2.0) input3= DOBType(0.0) order = c_wchar_p('f') num=c_int(1) rez= DLL.dgauss_(order,num,input1,input2, input3) print(' TEST PROGRAM D103 (DGAUSS)') print(rez)
from tkinter import * from decimal import * root = Tk() fr = Frame(root) fr_but = Frame(root) fr1 = Frame(root) def pr_nt(set): ent.insert(END,set) def stir(): ent.delete(0,END) ent = Entry(fr, text = ‘0’, width=15,justify=CENTER) b = Button(fr_but,width=1,height=1,text='1') b1 = Button(fr_but,width=1,height=1,text='2') b2 = Button(fr_but,width=1,height=1,text='3') b3 = Button(fr_but,width=1,height=1,text='4') b4 = Button(fr_but,width=1,height=1,text='5') b5 = Button(fr_but,width=1,height=1,text='6') b6 = Button(fr_but,width=1,height=1,text='7') b7 = Button(fr_but,width=1,height=1,text='8') b8 = Button(fr_but,width=1,height=1,text='9') b9 = Button(fr_but,width=1,height=1,text='0') b10 = Button(fr_but,width=1,height=1,text='/') b11 = Button(fr_but,width=1,height=1,text='*') b12 = Button(fr_but,width=1,height=1,text='-') b13 = Button(fr_but,width=1,height=1,text='+') b14 = Button(fr_but,width=1,height=1,text='=') b15 = Button(fr_but,width=1,height=1,text='C', command=stir) b.bind('<Button-1>', lambda event: pr_nt(1)) b1.bind('<Button-1>', lambda event: pr_nt(2)) b2.bind('<Button-1>', lambda event: pr_nt(3)) b3.bind('<Button-1>', lambda event: pr_nt(4)) b4.bind('<Button-1>', lambda event: pr_nt(5)) b5.bind('<Button-1>', lambda event: pr_nt(6)) b6.bind('<Button-1>', lambda event: pr_nt(7)) b7.bind('<Button-1>', lambda event: pr_nt(8)) b8.bind('<Button-1>', lambda event: pr_nt(9)) b9.bind('<Button-1>', lambda event: pr_nt(0)) b10.bind('<Button-1>') b11.bind('<Button-1>') b12.bind('<Button-1>') b13.bind('<Button-1>') b14.bind('<Button-1>') b15.bind('<Button-1>') fr.pack() ent.pack() fr_but.pack() b6.grid(row=0,column=0) b7.grid(row=0,column=1) b8.grid(row=0,column=2) b3.grid(row=1,column=0) b4.grid(row=1,column=1) b5.grid(row=1,column=2) b.grid(row=2,column=0) b1.grid(row=2,column=1) b2.grid(row=2,column=2) b9.grid(row=3,column=1) b10.grid(row=0,column=3) b11.grid(row=1,column=3) b12.grid(row=2,column=3) b13.grid(row=3,column=3) b14.grid(row=3,column=2) b15.grid(row=3,column=0) fr1.pack() root.mainloop()
from random import choice import requests as r import time s = r.Session() s.headers['authorization'] = input('Token: ') fname = 'msg.txt' with open(fname, encoding='utf-8') as fin: text = fin.read() chat_id = input('Input chat id: ') delay = int(input('Delay between messages in seconds: ')) total_sent = 0 while True: try: msg = text print(f'Sending message {msg}') _data = {'content': msg, 'tts': False} resp = s.post( f'https://discord.com/api/v9/channels/{chat_id}/messages', json=_data).json() msg_id = resp['id'] total_sent += 1 print(f'Message sent (Already {total_sent} in total).') print(f'Sleeping {delay} seconds') time.sleep(delay) except Exception as e: print(f'Some error: {e}') time.sleep(20)]
from tkinter import * from tkVideoPlayer import TkinterVideo num = 1 home = Tk() home.geometry("500x500+500+200") home.title("1 LVL") videoplayer = TkinterVideo(master=home, scaled=True) def print_key(event): global num args = event.keysym, event.keycode, event.char print("Знак: {}, Код: {}, Символ: {}".format(*args)) if event.keycode == 87: # KEY W if num != 10: num += 1 home.title(f"{num} LVL") play_video(num) elif event.keycode == 83: # KEY S if num != 1: num -= 1 home.title(f"{num} LVL") play_video(num) def play_video(num): videoplayer.load(f"UpGrow/{num}.mp4") videoplayer.pack(expand=True, fill="both") videoplayer.play() home.bind("<Key>", print_key) play_video(1) home.mainloop()
cap = cv2.VideoCapture('video.mp4') while(cap.isOpened()): ret, frame = cap.read() if ret == True:
IN: Довстречистобой
OUT: До встречи с тобой
IN: Разбежавшисьпрыгнусоскалы
OUT: Разбежавшись прыгну со скалы
[code python]
import requests
import telebot
# Укажите токен вашего бота
TOKEN = 'your_bot_token_here'
# Создаем экземпляр бота
bot = telebot.TeleBot(TOKEN)
# Обработчик команды /start
@bot.message_handler(commands=['start'])
def send_welcome(message):
bot.reply_to(message, "Привет! Введите команду /exchange, чтобы получить актуальные курсы валют.")
# Обработчик команды /exchange
@bot.message_handler(commands=['exchange'])
def send_exchange(message):
url = 'https://www.primbank.ru/local/cron/infoVl.php?idType=4&idCity=1'
response = requests.get(url)
if response.status_code == 200:
data = response.json()
# Отправляем сообщение с актуальными курсами валют
bot.reply_to(message, f"Курс USD: {data['USD']['buy']} / {data['USD']['sell']}\nКурс EUR: {data['EUR']['buy']} / {data['EUR']['sell']}")
else:
bot.reply_to(message, "Произошла ошибка при получении курсов валют.")
# Запускаем бота
bot.polling()
[/code]
def table(self): # создание таблицы self.table = QtWidgets.QTableWidget(self.centralwidget) self.table.setGeometry(QtCore.QRect(10, 50, 462, 950)) self.table.setStyleSheet("background-color:rgb(209, 209, 209)") self.headerLabels = list('A') n = 3000 self.table.setRowCount(n) self.table.setColumnCount(len(self.headerLabels)) self.table.setHorizontalHeaderLabels(self.headerLabels) self.table.horizontalHeader().setDefaultSectionSize(100) self.table.horizontalHeader().setMinimumSectionSize(125) self.table.verticalHeader().setVisible(False) self.table.verticalHeader().setDefaultSectionSize(25) self.table.verticalHeader().setMinimumSectionSize(25) for row in range(n): for col in range(len(self.headerLabels)): item = QTableWidgetItem(''.format(self.headerLabels[col], row)) self.table.setItem(row, col, item) self.table.resizeColumnsToContents() self.table.resizeRowsToContents()
class GraphicsView(QGraphicsView): # +++ clicked = pyqtSignal(str, str) def mousePressEvent(self, event): super(GraphicsView, self).mousePressEvent(event) self.setCursor(Qt.DragMoveCursor) # Получить положение мыши на экране pos = event.globalPos() image = QApplication.primaryScreen().grabWindow( int(QApplication.desktop().winId()), pos.x() - 23, pos.y() - 23, 47, 47).toImage() color = image.pixelColor(23, 23) if color.isValid(): self.clicked.emit('View', color.name()) def mouseReleaseEvent(self, event): super(GraphicsView, self).mouseReleaseEvent(event) self.setCursor(Qt.ArrowCursor)
class MainssWindow(QMainWindow, Ui_MainsWindow): def __init__(self): super().__init__() self.setupUi(self) self.layout = QtWidgets.QHBoxLayout(self.wid) self.layout.addWidget(self.wid) self.scene = GraphicsScene() self.scene.setSceneRect(0, 0, 1400, 900) width = Settings.NUM_BLOCKS_X * Settings.WIDTH height = Settings.NUM_BLOCKS_Y * Settings.HEIGHT self.scene.setSceneRect(0, 0, width, height) self.scene.setItemIndexMethod(QtWidgets.QGraphicsScene.NoIndex) self.setMouseTracking(True) self.graphicsView.setScene(self.scene) self.scene.clicked.connect(self.point1) self.graphicsView.clicked.connect(self.point1) # +++ self.table()
class QS(QtWidgets.QGraphicsScene): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) width = Settings.NUM_BLOCKS_X * Settings.WIDTH height = Settings.NUM_BLOCKS_Y * Settings.HEIGHT self.setSceneRect(0, 0, width, height) self.setItemIndexMethod(QtWidgets.QGraphicsScene.NoIndex) for x in range(0,Settings.NUM_BLOCKS_X+1): xc = x * Settings.WIDTH self.addLine(xc,0,xc,height) for y in range(0,Settings.NUM_BLOCKS_Y+1): yc = y * Settings.HEIGHT self.addLine(0,yc,width,yc)
class GraphicsScene(QGraphicsScene): clicked = pyqtSignal(str, QPointF) def mousePressEvent(self, event): super(GraphicsScene, self).mousePressEvent(event) sp = event.scenePos() self.clicked.emit('Scene', sp)
def point1(self, text, value): if text == 'Scene': self.lab.setText(f'x1 = {value.x()}, y1 = {value.y()}. Интенсивность: ') if text == 'View': self.lab.setText(f'{self.lab.text()} {value}')
import sys from pathlib import Path from PyQt5.QtWidgets import * app = QApplication(sys.argv) win = QWidget() win.setGeometry(1400, 1400, 1400, 1300) layout = QGridLayout() for i in range(5): for j in range(5): label = QLabel('plist_down.py') button1 = QPushButton('Open (E:\__Moi_scripti\03_yotube_plist_downloader)') button2 = QPushButton('Run Script') layout.addWidget(label, i, j) layout.addWidget(button1, i, j+1) layout.addWidget(button2, i, j+2) win.setLayout(layout) win.show() sys.exit(app.exec_())
import discord import os from discord.ext import commands from dotenv import load_dotenv import whisper from tts import tts from parse_statement import parse load_dotenv() intents = discord.Intents.all() client = commands.Bot(command_prefix="&", intents=intents) # model = whisper.load_model("base") model = whisper.load_model("small") # join vc @client.command() async def join(ctx): if ctx.author.voice: channel = ctx.message.author.voice.channel await channel.connect() else: await ctx.send("not in a voice channel!") # leave vc @client.command() async def leave(ctx): if ctx.voice_client: await ctx.voice_client.disconnect() else: await ctx.send("not in a voice channel!") # play tts audio from command @client.command() async def play(ctx, *, arg): tts(ctx, arg) @client.command() async def listen(ctx): if ctx.voice_client: ctx.voice_client.start_recording(discord.sinks.WaveSink(), callback, ctx) await ctx.send("listening...") else: await ctx.send("not in a voice channel!") async def callback(sink: discord.sinks, ctx): for user_id, audio in sink.audio_data.items(): if user_id == ctx.author.id: audio: discord.sinks.core.AudioData = audio print(user_id) filename = "audio.wav" with open(filename, "wb") as f: f.write(audio.file.getvalue()) text = model.transcribe(filename)["text"] os.remove(filename) print(f"Received from {ctx.author.name}: {text}") reply = parse(text) print(f"Reply: {reply}") tts(ctx, reply) # stops recording @client.command() async def stop(ctx): ctx.voice_client.stop_recording() @client.event async def on_ready(): print(f"We have logged in as {client.user}") @client.event async def on_message(message): await client.process_commands(message) if message.author == client.user: return # ping if message.content.startswith("ping"): await message.channel.send("pong") client.run(os.environ.get("DISCORD"))
(discord) PS D:\discord> & CUsers/Gena/.virtualenvs/discord-q4ERoUCO/Scripts/python.exe ddiscord/package/test/bot.py
Traceback (most recent call last):
File “d:\discord\package\test\bot.py”, line 7, in <module>
import whisper
File “C:\Users\Gena\.virtualenvs\discord-q4ERoUCO\lib\site-packages\whisper.py”, line 69, in <module>
libc = ctypes.CDLL(libc_name)
File “C:\Users\Gena\AppData\Local\Programs\Python\Python310\lib\ctypes\__init__.py”, line 364, in __init__
if ‘/’ in name or ‘\\’ in name:
TypeError: argument of type ‘NoneType’ is not iterable
(discord) PS D:\discord>