Move image with Pygame by file picked up by askfileopen()

well, I was fine, making my Pygame app with TkInter to get the file the user wants to open. is a .png or .jpeg file
my app is made up of def, it means that I use them to call them in while True in the main file

but the movement doesn’t work, although print works
print may print every time I press it, but the image remains still

By the way, this is the code I’m using to implement the Tkinter image:

# in tk.py

import tkinter as tk
import pygame
from tkinter import filedialog
from color import *             # i store my color tuple here
from J import *                 # all JSON file that contains my values
import surf                     # all Surfaces or Rectangles stored.

def open_file():
    
    file_t = ("*.png", "*.jpeg")

    global pos_x
    global pos_y
    global spd

    pos_x = 10
    pos_y = 10
    spd = 5

    file = filedialog.askopenfile(mode = "r", filetypes = [("Image file", file_t)])
    
    if (file):
        
        file_img = pygame.image.load(file)
    
        import mode
    
        surf.surf_image.fill(j_imageBG_color)
        surf.surf_image.blit(file_img, (pos_x, pos_y))
        
    else:
        
        print("none selected. I know.")

I’m new to Python, but I know a few things from Docs.
and these global variables are for the movement I’m trying to implement
my ev() function is for calling events.

# in ev.py

import pygame    as pyg
import tkinter
import sys       as sys
from setting     import *
from color       import *
from surf import *
import tk

def ev():
    for ev in pyg.event.get():

        if ev.type == pyg.QUIT:         # if you press the X in the window, it closes
            pyg.quit()                  # close
            exit()                      # close
            sys.exit()                  # close
            
        if ev.type == pyg.MOUSEBUTTONDOWN:
            
            mouse_pos = pygame.mouse.get_pos()
            import PYTHON_TESTS as p

            if rect_load.collidepoint(mouse_pos) and ev.button == 1: # if pressed on [ LOAD ]
                tk.open_file()

            if rect_save.collidepoint(mouse_pos) and ev.button == 1: # if pressed on [ SAVE ]
                tk.save_file()
                
        if ev.type == pyg.KEYDOWN:

            if ev.key == pygame.K_UP:

                tk.pos_x += tk.spd
                print("up")

and yes, this is the function that is calling all the others
it has time.Clock() here for fps

# in mode.py

from tk import *
from color import *
from setting import *
from e import *
from surf import *
from text import *
from J import *
import pygame

def mode_main():
    import PYTHON_TESTS as p
    
    pygame.display.set_caption(j_cap_main)

    window = pygame.display.set_mode(res)
    window.fill(back_col)
    
    while True:
        fps.tick(60)

        surface()
        txt()
        ev()

        pygame.display.update()

forgive me if it’s a mess, i dont know how to organize as well. They’re in separated files.

New contributor

Pedro Gabriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật