Найти - Пользователи
Полная версия: Не цепялется image к button
Начало » Python для новичков » Не цепялется image к button
1
XoFfiCEr
 def tabmode7_view():                                # разное
    x=tkright+5
    y=tktop+5
    imfile=dir_img+r'excel-logo.gif'
    el=PhotoImage(imfile)
    bw=120
    tab7_button_openlogfile=Button(tab7, text='Открыть журнальный файл', command=open_log_file, width=bw)
    tab7_button_openlogfile.config(font=ffont, cursor='hand2')
    tab7_button_openlogfile.place(x=x, y=y)
    y+=70
    tab7_button_exportrails=Button(tab7, image=el, text='Экспорт таблицы lines в CSV', command=export_lines_to_csv, width=bw, height=48)
    tab7_button_exportrails.config(font=ffont, cursor='hand2')
    tab7_button_exportrails.place(x=x, y=y)
    y+=70
    tab7_button_exportdefects=Button(tab7, image=el, text='Экспорт таблицы defects в CSV', command=export_defects_to_csv, width=bw, height=48)
    tab7_button_exportdefects.config(font=ffont, cursor='hand2')
    tab7_button_exportdefects.place(x=x, y=y)
Файл картинки точно существует, однако на кнопках картинки нету, да и кнопки стали почему то некликабельные.
ЧЯДНТ?
4kpt_IV
 import Image  
import ImageTk
#
img = Image.open(file_foto_name).resize(self.res_foto)
img_x = ImageTk.PhotoImage(Img)                       
XoFfiCEr
import Image
import ImageTk
ImageTk это вроде компонент python imaging library (pil)?
А что без него никак нельзя?
Tkinter выдает ошибку не найден модуль ImageTk я пробовал.
4kpt_IV
Можно, но тогда Вы будете сильно ограничены в возможных форматах (и .gif среди них нет)…
XoFfiCEr
4kpt_IV
Можно, но тогда Вы будете сильно ограничены в возможных форматах (и .gif среди них нет)…
То есть через BitmapImage?
XoFfiCEr
pil есть только для python 2.7
4kpt_IV
Pillow - тот же pil, только импорты немного другие
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB