본문 바로가기

개발/파이썬18

wxpython에서 항상 맨 위로 오는 윈도우 wxpython에서 항상 맨 위로 오는 윈도우는 wx.STAY_ON_TOP 스타일을 주면 된다. 생성시에 줘도 되고, 이미 만들어진 윈도우라면 다음과 같은 방법으로 변경할 수 있다. 스타일을 해제해주려면 self.SetWindowStyle(self.GetWindowStyle() & ~wx.STAY_ON_TOP) 스타일을 설정하려면 self.SetWindowStyle(self.GetWindowStyle() | wx.STAY_ON_TOP) 2021. 11. 27.
Flask의 make_response에서 TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a list. from flask_marshmallow import Marshmallow ma = Marshmallow() class UserSchema(SQLAlchemyAutoSchema): class Meta: model = User users = [User(), User(), User(), ...] data = UserSchema().dump(users, many=True) res = make_response(data) File "C:\Users\...\flask\app.py", line 2127, in make_response raise TypeError( TypeError: The view function did not return a valid response. The return type must be .. 2021. 11. 3.
파일 확장자로 mimetype 추측하기 기본 모듈인 mimetypes로 쉽게 할 수 있다. >>> import mimetypes >>> mimetypes.guess_type('image.png') ('image/png', None) >>> mimetypes.guess_extension('image/jpeg') '.jpg' >>> mimetypes.guess_type('image.tar.gz') ('application/x-tar', 'gzip') 반대로 mimetype으로도 파일 확장자를 추측할 수 있다. >>> mimetypes.guess_extension('image/jpeg') '.jpg' 끝. 2021. 2. 22.
Google Drive에서 파일을 받으려는데 The requested conversion is not supported가 난다면 HttpError 400 어쩌구 'The requested conversion is not supported.' 구글 스프레이드 파일을 받으려하니 자체 포멧(슬라이드, 스프레드시트 등)은 그대로 내보내지 못해서 발생한 오류가 발생했다. 요청한 mimeType으로 내려줄 수 없다는 의미로 https://developers.google.com/drive/api/v3/ref-export-formats Google Workspace documents and corresponding export MIME types Google Workspace formats and supported export MIME types map to each other as follows: Google Doc Format Convers.. 2021. 1. 30.